//public IEnumerable<OrderDetailViewModel> ViewAll() //{ // using (var repository = _sourceFactory.CreateRepository<OrderDetail, int>()) // { // //var list = repository.GetAll(). // // Select(c => new OrderTypeViewModel(c.OrderTypeId, c.OrderTypeName)); // //return list; // } //} //public OrderDetailViewModel ViewSingle(int id) //{ // //using (var repository = _sourceFactory.CreateRepository<OrderDetail, int>()) // //{ // // var orderType = repository.GetSingle(id); // // return new OrderTypeViewModel(orderType.OrderTypeId, orderType.OrderTypeName); // //} //} public bool Add(OrderDetailModifyModel entity) { using (var repository = _sourceFactory.CreateRepository <OrderDetail, int>()) { return(repository.Add(new OrderDetail { ProductId = entity.ProductId, OrderQTY = entity.OrderQTY, ProductPrice = entity.ProductPrice, ProductSum = entity.ProductSum, OrderId = entity.OrderId })); }; }
public bool Update(int id, OrderDetailModifyModel entity) { using (var repository = _sourceFactory.CreateRepository <OrderDetail, int>()) { var orderDet = repository.GetSingle(id); if (orderDet == null) { throw new NotFoundException(); } orderDet.ProductId = entity.ProductId; orderDet.OrderQTY = entity.OrderQTY; orderDet.ProductPrice = entity.ProductPrice; orderDet.ProductSum = entity.ProductSum; orderDet.OrderId = entity.OrderId; return(repository.Update(orderDet)); } }