コード例 #1
0
        public ActionResult Edit(PostCreateViewModel current)
        {
            if (ModelState.IsValid)
            {
                var model = current.ToPostCreateModel();
                model.AuthorId = UserManager.GetUserId(User.Identity.Name);
                EntityAction result = service.Update(model);
                if (result == EntityAction.Updated)
                {
                    current.State   = ActionState.Success;
                    current.Message = ApplicationMessages.UpdateSuccess;
                }
            }
            else
            {
                current.State   = ActionState.Error;
                current.Message = ApplicationMessages.ErrorHasBeen;
            }

            return(View("Create", current));
        }
コード例 #2
0
        public ActionResult Create(PostCreateViewModel current)
        {
            if (ModelState.IsValid)
            {
                current.SendDate = PersianDate.Now;
                var model = current.ToPostCreateModel();
                model.AuthorId = UserManager.GetUserId(User.Identity.Name);
                EntityAction result = service.Create(model);
                if (result == EntityAction.Added)
                {
                    current.State   = ActionState.Success;
                    current.Message = ApplicationMessages.InsertSuccess;
                }
            }
            else
            {
                current.State   = ActionState.Error;
                current.Message = ApplicationMessages.ErrorHasBeen;
            }

            return(View(current));
        }