示例#1
0
        public ActionResult EssaysUpdate([DataSourceRequest]DataSourceRequest request, EssayViewModel essay)
        {
            if (this.ModelState.IsValid)
            {
                var entity = this.Mapper.Map<Essay>(essay);
                this.essays.Update(entity);
            }

            return this.Json(new[] { essay }.ToDataSourceResult(request, this.ModelState));
        }
示例#2
0
        public ActionResult Edit(EssayViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var studentId = this.User.Identity.GetUserId();
                var updateModel = this.Mapper.Map<Essay>(model);
                updateModel.AuthorId = studentId;
                this.essays.Update(updateModel);

                return this.RedirectToAction(nameof(this.Review));
            }

            return this.View(model);
        }
示例#3
0
        public void TestRouteStudentEssayEditPost()
        {
            const string Url = "/Student/Essay/Edit";

            var model = new EssayViewModel()
            {
                Content = "Something",
                Title = "Test"
            };
            var jsonBody = JsonConvert.SerializeObject(model);

            this.RouteCollection
                .ShouldMap(Url)
                .WithJsonBody(jsonBody)
                .To<EssayController>(c => c.Edit());
        }
示例#4
0
        public ActionResult EssaysDestroy([DataSourceRequest]DataSourceRequest request, EssayViewModel essay)
        {
            this.essays.Delete(essay.AuthorId);

            return this.Json(new[] { essay }.ToDataSourceResult(request, this.ModelState));
        }