public ActionResult Edit(User model, HttpPostedFileBase imageFile)
 {
     if (ModelState.IsValid)
     {
         if (imageFile != null)
         {
             model.ImageMimeType = imageFile.ContentType;
             model.Image = new byte[imageFile.ContentLength];
             imageFile.InputStream.Read(model.Image, 0, imageFile.ContentLength);
         }
         var user = _repoUsers.GetById(User.Identity.Name);
         _repoUsers.Remove(user);
         _repoUsers.Add(model);
         return RedirectToAction("Index");
     }
     return View(model);
 }
        public ActionResult Register(User model)
        {
            if (ModelState.IsValid)
            {
                //Adicionar cifra e enviar email
                model.Type = "user";
                int rand = _repoCifra.Add(model);
                //Criar chave para desafio do email
                string key = rand.ToString(CultureInfo.InvariantCulture);

                //Enconding....
                var str = Encryptor.Encrypt(key);

                //Enviar Email
                var emailSender = new EmailSender();
                emailSender.ProcessEmail(model.Email, new Url("http://trellog16.apphb.com/Account/Validate/" + str));
                return RedirectToAction("LogOn");
            }
            return View();
        }
        public ActionResult LogOn(User model)
        {
            //Tentar localizar user no repo
            var user = _repoUsers.GetById(model.Nickname);

            ModelState.Remove("Name");
            ModelState.Remove("Email");

            if (ModelState.IsValid && user != null)
            {
                var u = _authProvider.Authenticate(user.Nickname, model.Password);
                if (u != null)
                {
                    return RedirectToAction("Index", "Home");
                }
                ModelState.AddModelError("", "Password invalid!");
                return View();
            }
            ModelState.AddModelError("", "Nickname invalid!");
            return View();
        }