コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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);
     }
 }