public ActionResult AddEdition(Guid contractId)
        {
            var model = new EditionEditViewModel()
            {
                ContractId = contractId
            };

            return(View("CreateEdition", model));
        }
        public ActionResult AddEdition(EditionEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateEdition", model));
            }

            var extensionCover = Path.GetExtension(model.Cover.FileName);

            if (!(extensionCover == ".png" || extensionCover == ".jpg"))
            {
                ModelState.AddModelError("", @"Extension for cover should be '.png' or '.jpg'");

                return(View("CreateEdition", model));
            }

            var extensionFile = Path.GetExtension(model.File.FileName);

            if (extensionFile != ".pdf")
            {
                ModelState.AddModelError("", @"Extension for file should be '.pdf'");

                return(View("CreateEdition", model));
            }

            model.FileName  = Guid.NewGuid() + extensionFile;
            model.CoverName = Guid.NewGuid() + extensionCover;

            model.File.SaveAs(Server.MapPath("../Storage/" + model.FileName));
            model.Cover.SaveAs(Server.MapPath("../Storage/" + model.CoverName));

            var edition = new Edition();

            Mapper.Map(model, edition);

            _editionService.AddEdition(edition);

            return(RedirectToAction("GetAllEditionsForPublisher"));
        }
 public ActionResult EditEdition(EditionEditViewModel edition)
 {
     Mapper.CreateMap<EditionEditViewModel, EditionEdit>();
     editorService.EditEdition(Mapper.Map<EditionEditViewModel, EditionEdit>(edition));
     return RedirectToAction("Index");
 }
 public ActionResult DeleteEdition(EditionEditViewModel edition)
 {
     editorService.DeleteEdition(edition.EditionId);
     return RedirectToAction("Index");
 }