public void SavePrice(RS_PRICE price) { price.PriceWithoutVat = 0; //change trigger database price.DateEnd = price.DateEnd ?? DateTime.MaxValue.Date; if (price.PriceId == 0) { context.RS_PRICE.Add(price); } else { RS_PRICE dbEntry = context.RS_PRICE.Where(x => x.PriceId == price.PriceId).Single(); if (dbEntry != null) { dbEntry.ProductId = price.ProductId; dbEntry.VatId = price.VatId; dbEntry.PriceWithVat = price.PriceWithVat; dbEntry.PriceWithoutVat = price.PriceWithoutVat; dbEntry.DateBegin = price.DateBegin; dbEntry.DateEnd = price.DateEnd; dbEntry.RS_PRODUCT = price.RS_PRODUCT; dbEntry.CT_VAT = price.CT_VAT; } } context.SaveChanges(); }
public ActionResult PriceDelete(long priceId) { RS_PRICE deletedPrice = repository.DeletePrice(priceId); if (deletedPrice != null) { TempData["message"] = string.Format("{0} был удален", deletedPrice.PriceId.ToString()); } return(RedirectToAction("Prices")); }
public RS_PRICE DeletePrice(long priceId) { RS_PRICE dbEntry = context.RS_PRICE.Where(x => x.PriceId == priceId).Single(); if (dbEntry != null) { context.RS_PRICE.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public ViewResult PriceEdit(long priceId) { RS_PRICE price = repository.Prices.Where(x => x.PriceId == priceId).FirstOrDefault(); IEnumerable <RS_PRODUCT> products = repository.Productts; IEnumerable <CT_VAT> vats = repository.Vats; var priceVM = new PriceViewModel { Price = price, Products = products, Vats = vats }; return(View(priceVM)); }