public ActionResult RemovePromo(int PromoId) { try { Promo promo = PromoService.GetPromo(PromoId); PromoService.SavePromo(); Product product = ProductService.GetProduct(promo.ProductId); product.TagsText = "Ta5Fabrixs"; product.PriceEU = product.OriginalPriceEU; PromoService.RemovePromo(promo.ProductId); PromoService.SavePromo(); return(RedirectToAction("Promos")); } catch (DbEntityValidationException e) { string resultingError = ""; foreach (var eve in e.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { resultingError += "- Property: " + ve.PropertyName + ", Error: " + ve.ErrorMessage + ""; } } throw new Exception(resultingError); } }
public void CheckForSalesAndDoThem() { try { PromoService.UpdateAllPromos(); PromoService.SavePromo(); } catch (DbEntityValidationException e) { string resultingError = ""; foreach (var eve in e.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { resultingError += "- Property: " + ve.PropertyName + ", Error: " + ve.ErrorMessage + ""; } } throw new Exception(resultingError); } }