コード例 #1
0
 public ActionResult GetOffer(int id)
 {
     OfferViewModel offerVM = new OfferViewModel();
     if (id > 0)
     {
         var offer = OfferService.GetOffer(id);
         offerVM = OfferViewModel.ConvertToOfferViewModel(offer);
     }
     return Json( offerVM, JsonRequestBehavior.AllowGet);
 }
コード例 #2
0
 public static Offer ConvertToOffer(OfferViewModel offerViewModel)
 {
     return new Offer
     {
         IdOffer = offerViewModel.IdOffer,
         IdUser= offerViewModel.IdUser,
         NameOffer = offerViewModel.NameOffer,
         Description = offerViewModel.Description,
         Date = ParseJsDate(offerViewModel.Date),
         Type = offerViewModel.Type
     };
 }
コード例 #3
0
 public static Offer ConvertToOffer(OfferViewModel offerViewModel)
 {
     return(new Offer
     {
         IdOffer = offerViewModel.IdOffer,
         IdUser = offerViewModel.IdUser,
         NameOffer = offerViewModel.NameOffer,
         Description = offerViewModel.Description,
         Date = ParseJsDate(offerViewModel.Date),
         Type = offerViewModel.Type
     });
 }
コード例 #4
0
        public static OfferListViewModel CreateOfferListViewModel(int page, int pageSize, long countOffers, int totalPagesCount, List <Offer> items)
        {
            var model = new OfferListViewModel();

            model.Paging = Paging.CreatePaging(page, countOffers, pageSize, totalPagesCount);
            model.Offers = new List <OfferViewModel>();
            foreach (Offer DMOffer in items)
            {
                OfferViewModel tempOffer = OfferViewModel.ConvertToOfferViewModel(DMOffer);
                model.Offers.Add(tempOffer);
            }

            return(model);
        }
コード例 #5
0
 public void SaveOffer(OfferViewModel offerViewModel)
 {
     var offer = OfferViewModel.ConvertToOffer(offerViewModel);
     if (!OfferService.Save(offer))
     {
         /*if ((offer.IdOffer == 0) && (OfferService.ExistOffers(offer.NameOffer)))
         {
             ModelState.AddModelError("NameOffer", "This name is already exists!");
         }*/
     }
 }