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); }
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 }; }
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 }); }
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); }
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!"); }*/ } }