public void SaveOrder(WAGUser user, MakeOrderViewModel makeOrderViewModel) { var artwork = ArtisticWorkService.GetArtisticWorkById(makeOrderViewModel.ArtWorkId); if (makeOrderViewModel.TelephoneNumberForContact == null) { makeOrderViewModel.TelephoneNumberForContact = user.PhoneNumber; } if (makeOrderViewModel.DeliveryAddress == null) { makeOrderViewModel.DeliveryAddress = user.Address; } var order = new Order() { WAGUser = user, ArtisticWork = artwork, OrderInfo = makeOrderViewModel.OrderInfo, TelephoneNumberForContact = makeOrderViewModel.TelephoneNumberForContact, DeliveryAddress = makeOrderViewModel.DeliveryAddress, CreatedOn = DateTime.UtcNow }; this.DbContext.Orders.Add(order); this.DbContext.SaveChanges(); }
public IActionResult DeleteArtWork(int id, ArtWorkDetailsViewModel artWorkDetailsViewModel) { artWorkDetailsViewModel.ArtisticWork = ArtisticWorkService.GetArtisticWorkById(id); if (artWorkDetailsViewModel.ArtisticWork == null) { return(RedirectToAction("Categories", "ArtisticWork", new { area = "" })); } return(View(artWorkDetailsViewModel)); }
public IActionResult ArtWorkDetails(int id) { var viewModel = new ArtWorkDetailsViewModel(); viewModel.ArtisticWork = ArtisticWorkService.GetArtisticWorkById(id); if (viewModel.ArtisticWork == null) { return(RedirectToAction("Categories", "ArtisticWork")); } viewModel.ArtisticWork.ArtisticWorkCategory = ArtisticWorkService.GetCategoryById(viewModel.ArtisticWork.ArtisticWorkCategoryId); return(View(viewModel)); }
public IActionResult DeleteArtWork(int id) { ArtisticWork artWorkToDelete = ArtisticWorkService.GetArtisticWorkById(id); if (artWorkToDelete == null) { return(RedirectToAction("Categories", "ArtisticWork", new { area = "" })); } var ViewModel = mapper.Map <DeleteArtWorkViewModel>(artWorkToDelete); ViewModel.Cloudinary = this.cloudinaryService.GetCloudinaryInstance(); return(View(ViewModel)); }
public IActionResult ArtWorkDetails(int id) { var currArtWork = ArtisticWorkService.GetArtisticWorkById(id); if (currArtWork == null) { return(RedirectToAction("Categories", "ArtisticWork")); } var currArtWorkCategory = ArtisticWorkService.GetCategoryById(currArtWork.ArtisticWorkCategoryId); var viewModel = mapper.Map <ArtWorkDetailsViewModel>(currArtWork); viewModel.ArtWorkCategory = mapper.Map <ArtWorkCategoryViewModel>(currArtWorkCategory); viewModel.Cloudinary = this.cloudinaryService.GetCloudinaryInstance(); return(View(viewModel)); }