public ActionResult Specials(AdminSpecialVM model) { _specialManager = SpecialManagerFactory.Create(); if (ModelState.IsValid) { try { var response = _specialManager.SaveSpecial(model.Special); if (!response.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}")); } } catch (Exception ex) { throw ex; } } else { var response = _specialManager.GetAllSpecials(); model.SetSpecialItems(response.Specials); return(View(model)); } return(RedirectToAction("Specials")); }
public ActionResult Index() { //get managers ListingManager listingManager = ListingManagerFactory.Create(); SpecialManager specialManager = SpecialManagerFactory.Create(); //get responses ListingFeaturedResponse listingFeaturedResponse = listingManager.GetFeaturedListings(); SpecialGetAllResponse specialResponse = specialManager.GetAllSpecials(); //validate responses if (!listingFeaturedResponse.Success || !specialResponse.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{listingFeaturedResponse.Message} {specialResponse.Message}")); } else { //build vm HomeVM model = new HomeVM(); model.SetFeaturedListingItems(listingFeaturedResponse.Listings); model.SetSpecialItems(specialResponse.Specials); return(View(model)); } }
public ActionResult DeleteSpecial(int id) { _specialManager = SpecialManagerFactory.Create(); var response = _specialManager.DeleteSpecial(id); if (!response.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}")); } return(RedirectToAction("Specials")); }
public ActionResult Specials() { _specialManager = SpecialManagerFactory.Create(); var model = new AdminSpecialVM(); var response = _specialManager.GetAllSpecials(); if (!response.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}")); } else { model.SetSpecialItems(response.Specials); return(View(model)); } }
public ActionResult Specials() { //get manager SpecialManager manager = SpecialManagerFactory.Create(); //get response SpecialGetAllResponse response = manager.GetAllSpecials(); //validate if (!response.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. Message: {response.Message}")); } else { //create vm SpecialListVM model = new SpecialListVM(); model.SetSpecialItems(response.Specials); return(View(model)); } }