public void Test_mapping_property_between_two_object() { var novel = new Novel(); var novelForm = new NovelForm { Title = "test title", Synopsis = "test sysnopsis" }; new PropertyMapper <NovelForm, Novel>(novelForm, novel).Map(null); Assert.AreEqual(novelForm.Title, novel.Title); }
public int SaveChanges(NovelForm novelForm) { var tNovel = Table <Novel>(); var novel = tNovel.GetOrAdd(w => w.ID == novelForm.ID); UpdateAuditFields(novel, novelForm.ByUserID); MapProperty(novelForm, novel, novelForm.InlineEditProperty); // save SaveChanges(); return(novel.ID); }
public JsonResult Form(NovelForm form, HttpPostedFileBase image, string imagePath) { if (image != null && image.ContentLength > 0) { imagePath = string.IsNullOrWhiteSpace(imagePath) ? "/Fanslations/Novels/" + form.Title.ToSeo() : imagePath; var driveService = GoogleDriveService.GetDriveService(); var fileID = GoogleDriveService.uploadFile(driveService, image.InputStream, image.FileName, imagePath); form.ImageUrl = fileID; } return(SaveChanges(form, Facade <NovelFacade>().AddNovel)); }
public int AddNovel(NovelForm form) { using (var uow = UnitOfWorkFactory.Create <NovelContext>()) { var service = new NovelService(uow); var id = service.SaveChanges(form); if (form.Glossaries != null && form.InlineEditProperty == form.PropertyName(m => m.Glossaries)) { foreach (var glossary in form.Glossaries) { var glossaryService = new GlossaryService(uow); var glossaryForm = new GlossaryForm(); new PropertyMapper <Glossary, GlossaryForm>(glossary, glossaryForm).Map(); glossaryForm.SourceID = id; glossaryForm.SourceTable = R.SourceTable.NOVEL; glossaryForm.ByUserID = form.ByUserID; var glossaryID = glossaryService.SaveChanges(glossaryForm); } } return(id); } }
public ActionResult Add(NovelForm form) { return(View(form)); }