Esempio n. 1
0
 public DataObjectOperationResult CommitChanges(AuthorFormModel postedData)
 {
     Mapper.CreateMap<AuthorFormModel, Author>();
     var author = new Author(Db);
     Mapper.Map<AuthorFormModel, Author>(postedData, author);
     return author.Save();
 }
Esempio n. 2
0
        public AuthorFormModel GenerateForm()
        {
            var vModel = new AuthorFormModel()
                             {
                                 Books = new List<IBook>(),
                                 Characters = new List<ICharacter>()
                             };
            BuildFormDdLs(vModel);

            return vModel;
        }
Esempio n. 3
0
        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");
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public AuthorFormModel GenerateForm()
        {
            var vModel = new AuthorFormModel();

            return vModel;
        }