public DataObjectOperationResult CommitChanges(AuthorFormModel postedData) { Mapper.CreateMap<AuthorFormModel, Author>(); var author = new Author(Db); Mapper.Map<AuthorFormModel, Author>(postedData, author); return author.Save(); }
public AuthorFormModel GenerateForm() { var vModel = new AuthorFormModel() { Books = new List<IBook>(), Characters = new List<ICharacter>() }; BuildFormDdLs(vModel); return vModel; }
public void BuildFormDdLs(AuthorFormModel vModel) { var bookChoices = Book.GetAll(Db).ToList().Except(vModel.Books); vModel.BookAssoiationOptions = ListToSelectList.ConvertToSelectList( bookChoices, "Id", "Title", true, "Select Book To Add"); var characterChoices = Character.GetAll(Db).ToList().Except(vModel.Characters); vModel.CharacterAssoiationOptions = ListToSelectList.ConvertToSelectList( characterChoices, "Id", "Name", true, "Select Character To Add"); }
public ActionResult AddUpatde(AuthorFormModel PostedData) { var results = AWorker.CommitChanges(PostedData); if(results.Success) { return View("InputSuccess", results); } PostedData.PopupTitle = "Edit Author - ERROR"; results.PassErrorsToMvcModelState(ModelState); return View("Form", PostedData); }
public ActionResult AddUpatde(AuthorFormModel postedData) { bool isNew = postedData.Id == null; var results = AWorker.CommitChanges(postedData); if (results.Success) { if(isNew) { return RedirectToAction("Edit", new {aID = postedData.Id}); } return View("InputSuccess", results); } postedData.PopupTitle = "Edit Author - ERROR"; results.PassErrorsToMvcModelState(ModelState); return View("Form", postedData); }
public AuthorFormModel GenerateForm() { var vModel = new AuthorFormModel(); return vModel; }