示例#1
0
        public ActionResult Create(ApplicationUser user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var pic    = string.Empty;
                    var folder = "~/Content/Images";

                    if (user.Pic != null)
                    {
                        pic = ImageService.UploadPicture(user.Pic, folder);
                        if (!string.IsNullOrEmpty(pic))
                        {
                            user.Image = string.Format("{0}/{1}", folder, pic);
                        }
                    }
                    db.Users.Add(user);
                    db.SaveChanges();
                    userServ.CreateUserAsp(user.Email, "User", "123@Senha");
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }

            return(View(user));
        }