public async Task Check12CreateResetDtoOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new CreateServiceAsync(db); var dto = new DetailPostDtoAsync(); //ATTEMPT await service.ResetDtoAsync(dto); //VERIFY dto.Bloggers.ShouldNotEqualNull(); dto.Bloggers.KeyValueList.Count.ShouldNotEqual(0); } }
public async void Check26UpdateServiceResetWorksOk() { using (var db = new SampleWebAppDb()) { //SETUP var service = new UpdateServiceAsync <Post, DetailPostDtoAsync>(db); //ATTEMPT var dto = new DetailPostDtoAsync(); await service.ResetDtoAsync(dto); //VERIFY dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1); dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count()); } }
public async Task<ActionResult> Edit(DetailPostDtoAsync dto, IUpdateServiceAsync service) { if (!ModelState.IsValid) //model errors so return immediately return View(await service.ResetDtoAsync(dto)); var response = await service.UpdateAsync(dto); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return RedirectToAction("Index"); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, dto); return View(dto); }
public async Task <ActionResult> Create(DetailPostDtoAsync dto, ICreateServiceAsync service) { if (!ModelState.IsValid) { //model errors so return immediately return(View(await service.ResetDtoAsync(dto))); } var response = await service.CreateAsync(dto); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return(RedirectToAction("Index")); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, dto); return(View(dto)); }