Beispiel #1
0
 public ActionResult Registration(RegistrationModel model, HttpPostedFileBase image = null)
 {
     if (ModelState.IsValid)
     {
         if (image != null)
         {
             model.ImgType = image.ContentType;
             model.ImgData = new byte[image.ContentLength];
             image.InputStream.Read(model.ImgData, 0, image.ContentLength);
         }
         bool result = userService.SaveNewUser(model);
         if (result)
         {
             var user = userService.GetUser(model.Email);
             if (emailService.ConfirmEmailSend(user,
                                               string.Format(
                                                   "Для завершения регистрации перейдите по ссылке:" +
                                                   "<a href=\"{0}\" title=\"Подтвердить регистрацию\">{0}</a>",
                                                   Url.Action("ConfirmEmail", "Account", new { Token = user.Id, Email = user.Email },
                                                              Request.Url.Scheme))))
             {
                 ModelState.AddModelError("",
                                          "На указанный email выслано письмо, действуйте согласно инструкциям для активации аккаунта.");
                 return(View(model));
             }
             else
             {
                 ModelState.AddModelError("", "Ошибка отправки email, свяжитесь с админом");
                 return(View(model));
             }
         }
         ModelState.AddModelError("", "Данный email уже занят!");
     }
     return(View(model));
 }