Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
 public ActionResult Add(NovelForm form)
 {
     return(View(form));
 }