Exemplo n.º 1
0
        public void AddGet(AddBrochureViewModel view)
        {
            var publication = InsertPablication(view);

            InsertBrochure(view, publication);
            InsertPublicationInPublisihngHouse(view, publication);
        }
Exemplo n.º 2
0
 public ActionResult Add(AddBrochureViewModel view)
 {
     if (view == null)
     {
         return(RedirectToAction("Index", "Brochure"));
     }
     _service.AddGet(view);
     return(RedirectToAction("Index", "Brochure"));
 }
Exemplo n.º 3
0
        public Publication InsertPablication(AddBrochureViewModel view)
        {
            var publication = new Publication();

            publication.Name = view.PublicationName;
            publication.Type = PublicationType.Brochure;
            _publicationRepository.Insert(publication);
            _publicationRepository.Save();
            return(publication);
        }
Exemplo n.º 4
0
        public void InsertBrochure(AddBrochureViewModel view, Publication publication)
        {
            var BrochureNew = new Brochure();

            BrochureNew.CoverType      = view.CoverType;
            BrochureNew.NumberPages    = view.NumberPages;
            BrochureNew.Publication    = publication;
            BrochureNew.PublishingYear = view.PublishingYear;
            BrochureNew.TomFilling     = view.TomFilling;
            _brochureRepository.Insert(BrochureNew);
            _brochureRepository.Save();
        }
Exemplo n.º 5
0
        public void AddBrochure(AddGeneralViewModel view)
        {
            var addBrochureViewModel = new AddBrochureViewModel();

            addBrochureViewModel.CoverType           = view.CoverType;
            addBrochureViewModel.NumberPages         = view.NumberPages;
            addBrochureViewModel.PublicationName     = view.PublicationName;
            addBrochureViewModel.PublishingHousesIds = view.PublishingHousesIds;
            addBrochureViewModel.PublishingYear      = view.PublishingYear;
            addBrochureViewModel.TomFilling          = view.TomNumber;
            var publication = InsertPablication(addBrochureViewModel);

            InsertBrochure(addBrochureViewModel, publication);
            InsertPublicationInPublisihngHouse(addBrochureViewModel, publication);
        }
Exemplo n.º 6
0
 public void InsertPublicationInPublisihngHouse(AddBrochureViewModel view, Publication publication)
 {
     string[] subStrings = view.PublishingHousesIds.Split(',');
     foreach (var subString in subStrings)
     {
         if (subString == Errors.Error.ToString())
         {
             continue;
         }
         var publishingHouse = _publishingHouses.Where(x => x.Id == subString).FirstOrDefault();
         var publicationInPublisihngHouseRepository = _publicationInPublisihngHouses.Where(x =>
                                                                                           x.Publication.Id == publication.Id && x.PublishingHouse.Id == publishingHouse.Id).FirstOrDefault();
         if (publicationInPublisihngHouseRepository == null)
         {
             var publicationInPublisihngHouse = new PublicationInPublisihngHouse();
             publicationInPublisihngHouse.Publication     = publication;
             publicationInPublisihngHouse.PublishingHouse = publishingHouse;
             _publicationInPublisihngHouseRepository.Insert(publicationInPublisihngHouse);
             _publicationInPublisihngHouseRepository.Save();
         }
     }
 }