public ActionResult Create(CreateAuctionsViewModel model) { Auction auction = new Auction(); auction.Title = model.Title; auction.categoryID = model.categoryID; auction.Description = model.Description; auction.ActualAmount = model.ActualAmount; auction.StartingTime = model.StartingTime; auction.EndTime = model.EndTime; //LINQ var pictureIDs = model.AuctionPictures.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(ID => int.Parse(ID)).ToList(); auction.AuctionPictures = new List <AuctionPicture>(); auction.AuctionPictures.AddRange(pictureIDs.Select(x => new AuctionPicture() { PictureID = x }).ToList()); AuctionsService service = new AuctionsService(); service.SaveAuction(auction); return(RedirectToAction("Index")); }
public ActionResult Create() { CreateAuctionsViewModel model = new CreateAuctionsViewModel(); model.categories = categoriesService.GetAllCategories(); return(PartialView(model)); }
public ActionResult Edit(int ID) { CreateAuctionsViewModel model = new CreateAuctionsViewModel(); var auction = auctionService.GetAuctionByID(ID); model.ID = auction.ID; model.Title = auction.Title; model.CategoryID = auction.CategoryID; model.Description = auction.Description; model.ActualAmount = auction.ActualAmount; model.StaringTime = auction.StaringTime; model.EndTime = auction.EndTime; model.Categories = categoriesService.GetAllCategories(); model.AuctionPictureList = auction.AuctionPictures; return(PartialView(model)); }
public ActionResult Edit(CreateAuctionsViewModel model) { Auction auction = new Auction(); auction.ID = model.ID; auction.Title = model.Title; auction.CategoryID = model.CategoryID; auction.Description = model.Description; auction.ActualAmount = model.ActualAmount; auction.StaringTime = model.StaringTime; auction.EndTime = model.EndTime; if (!string.IsNullOrEmpty(model.AuctionPictures)) { var pictureIDs = model.AuctionPictures.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(ID => int.Parse(ID)).ToList(); auction.AuctionPictures = new List <AuctionPicture>(); auction.AuctionPictures.AddRange(pictureIDs.Select(x => new AuctionPicture() { AuctionID = auction.ID, PictureID = x }).ToList()); } auctionService.updateAuction(auction); return(RedirectToAction("Listing")); }