예제 #1
0
 public void UpdateBlog(Blog blog)
 {
     _blogRepository.Update(blog);
 }
예제 #2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                var createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
                    var user = _userService.GetUser(model.UserName);
                    user.Name = model.Name;
                    user.Surname = model.Surname;
                    if (model.Image != null)
                    {
                        user.Userpic = ImageService.SaveImage(model.Image);
                    }
                    _userService.EditUser(user);

                    var blog = new Blog
                    {
                        BlogName = model.BlogName,
                        BlogSubtitle = model.BlogSubtitle,
                        User = user,
                    };
                    _blogService.CreateBlog(blog);
                    return RedirectToAction("Blogs", "Blog");
                }
                ModelState.AddModelError("", ErrorCodeToString(createStatus));
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #3
0
 public void CreateBlog(Blog blog)
 {
     _blogRepository.Create(blog);
 }