示例#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);
 }