public bool SetPrice(PriceDataContract priceDC) { Price priceEF = new Price(); priceEF.PriceInclVAT = priceDC.PriceInclVAT; priceEF.PricePerUnit = priceDC.PricePerUnit; //itemEF.Price1 = itemDC.Price1; try { context.PriceSet.Add(priceEF); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); }
public bool UpdatePrice(PriceDataContract priceDC) { Price priceEF = new Price(); priceEF = context.PriceSet.FirstOrDefault(x => x.Id == priceDC.Id); priceEF.PriceInclVAT = priceDC.PriceInclVAT; priceEF.PricePerUnit = priceDC.PricePerUnit; //priceEF.UnitOfMeasure = itemDC.UnitOfMeasure; //itemEF.Price1 = itemDC.Price1; try { //context.ShopSet.Add(shopEF); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); }
public List <PriceDataContract> GetPricesByItem(int?itemId) { List <PriceDataContract> pricessDC = new List <PriceDataContract>(); List <Price> pricesEF = context.PriceSet.Where(x => x.ItemId == itemId).ToList(); foreach (var priceEF in pricesEF) { PriceDataContract priceDC = new PriceDataContract(); //priceDC.Discount = priceEF.Discount; //priceDC.DiscountsId = priceEF.DiscountId; priceDC.Id = priceEF.Id; //priceDC.Item = priceEF.Item; priceDC.ItemId = priceEF.ItemId; priceDC.PriceInclVAT = priceEF.PriceInclVAT; priceDC.PricePerUnit = priceEF.PricePerUnit; //priceDC.Shop = priceEF.Shop; priceDC.ShopId = priceEF.ShopId; pricessDC.Add(priceDC); } return(pricessDC); }