NancyFX, it’s awesome!

I don’t know about you, but I’m tired of all heavy, dirty and messy frameworks, etc like ASP.NET WebForms (ugh), MVC, and so on. It’s not practical, it’s not simple, there’s no fun on working with it. I don’t know if you ever seen Sinatra. To get an example of how simple and beautiful it is, just take a look at the quick example on it’s homepage:

require 'sinatra'

get '/hi' do
  "Hello World!"
end

It’s clean, as soon as you put your eyes on it, you know what’s going on, right? Now, if you are a .Net programmer and you’ve never seen light frameworks such as Nancy, you are thinking right now: “it’s impossible to do something like this on the heavy n’ old asp.net”.
and if I say that it is possible? Not as simple as that 4 lines of code, but almost there! Take a look at the code below:

using Nancy;

namespace me.Modules
{
    public class HomeModule : NancyModule
    {
        public HomeModule()
        {
            Get["/"] = _ => "Hello World!";
        }
    }
}

That’s how you do the sinatra way on .net! It’s simple, quick, light, beautiful, and still .net, still c#. We’re almost there ruby developers =D. If we could get rid of those ugly brackets…
But you know how we can do that? I’m not going to show you more code, I’m not going to give you a ~cake recipe~, like i did before with nhibernate, asp.net mvc and so on… and it’s not beacause I’m lazy right now, but it’s because you don’t need!
Open you Visual Studio, create an empty asp.net project. Now that you have an empty project, type: Install-Package Nancy.Hosting.Aspnet.
Now go on, create a class called HomeModule and copy n’ paste the code above and thats it! If you like, just go to my github and see by yourself the project 😉 https://github.com/ceb10n/beauty-nancyfx.

See yah! 😉

Anúncios

TUTORIAL: ASP.NET MVC COM NHIBERNATE E MYSQL – PARTE 2 – Criando o Repository

Na primeira parte do tutorial, nós mapeamos o nosso modelo utilizando o Mapping By Code do NHibernate. Como nosso modelo é basicamente um usuário com endereço, caso você queira popular o seu banco com os países, cidades e estados disponíveis, eu criei este gist no github.
Bem, vamos começar agora com o acesso aos dados. Vamos criar um Repository para o nosso usuário contendo as operações básicas: Salvar, Atualizar, Obter 1 usuário e Obter uma lista de usuários:

Continuar lendo

Editar imagem com ASP.NET e Ajax

Boa tarde!
Bom, neste post eu falarei um pouco sobre como manipular imagens. O código que realmente interessa é basicamente C#, e pode ser utilizado tanto em windows forms quanto em asp.net. O exemplo aqui será em asp.net 4.0, mas nada impede que seja utilizado em windows forms. Eu disponibilizarei o projeto no github. Basta acessar o link: https://github.com/ceb10n/exemplo-image-write.

Agora vamos ao que interessa.

Continuar lendo