public List <CustomerProductModel> DeleteCustomerProduct(long Id, long orderId) { List <CustomerProductModel> lstcsproducts = new List <CustomerProductModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { CustomerProduct customerProduct = GetCustomerProduct(db, Id); customerProduct.IsActive = false; db.CustomerProducts.Remove(customerProduct); db.SaveChanges(); var lstproducts = db.CustomerProducts.Where(m => m.OrderID == orderId && m.IsActive).ToList(); foreach (var cusprod in lstproducts) { CustomerProductModel objcsproducts = new CustomerProductModel(); cusprod.CopyProperties(objcsproducts); lstcsproducts.Add(objcsproducts); } } catch (Exception) { } return(lstcsproducts); } }
public static CustomerProductViewModel ToCustomerCatalogProductViewModel( this CustomerProductModel customerCatalogProduct, string imageServerPath) { //return new CustomerProductViewModel //{ // Id = customerCatalogProduct.ProductId, // Name = customerCatalogProduct.Name, // Description = customerCatalogProduct.Description, // Vendor = customerCatalogProduct.Vendor, // ImgUrl = customerCatalogProduct.Img, // activatedDate = customerCatalogProduct.activatedDate, // ProductItems = customerCatalogProduct.ProductItems.Select(c => c.ToCustomerCatalogProductItemViewModel(imageServerPath)) //}; return(new CustomerProductViewModel { Id = customerCatalogProduct.ProductId, Name = customerCatalogProduct.Name, Description = customerCatalogProduct.Description, Vendor = customerCatalogProduct.Vendor, ImgUrl = customerCatalogProduct.Img, activatedDate = customerCatalogProduct.activatedDate, CategoryId = customerCatalogProduct.CategoryId, ProductItems = customerCatalogProduct.ProductItems.Select(c => c.ToCustomerCatalogProductItemViewModel(imageServerPath)) }); }
public async Task <ResponseModel> DeleteCustomerProduct(CustomerProductModel objInput) { try { return(new ResponseModel { Status = HttpStatusCode.OK, Success = "" }); } catch (System.Exception ex) { return(new ResponseModel { Status = HttpStatusCode.InternalServerError, Errors = new[] { "Exception:" + ex.Message } }); } }
public ActionResult AddOrderProduct(CustomerProductModel objOrderProduct) { OrderModel objOrderModel = new OrderModel(); if ((OrderModel)TempData["cusproduct"] != null) { objOrderModel = (OrderModel)TempData["cusproduct"]; } List <CustomerProductModel> objCustomerProductModel = new List <CustomerProductModel>(); objCustomerProductModel.Add(objOrderProduct); objOrderModel.lstcusProduct = objCustomerProductModel; TempData["cusproduct"] = objOrderModel; return(Json(objOrderModel, JsonRequestBehavior.AllowGet)); //return PartialView("~/Views/Shared/_AddCustomerProduct.cshtml", objOrderModel); }
public async Task <ResponseModel> AddCustomerProduct(CustomerProductModel objInput) { try { await _repository.Create <CustomerProduct>(_mapper.Map <CustomerProduct>(objInput)); await _unitofWork.SaveChangesAsync(); return(new ResponseModel { Status = HttpStatusCode.OK, Success = "Product added successfully" }); } catch (System.Exception ex) { return(new ResponseModel { Status = HttpStatusCode.InternalServerError, Errors = new[] { "Exception:" + ex.Message } }); } }
public List <CustomerProductModel> AddCustomerProduct(CustomerProductModel customerProductModel) { List <CustomerProductModel> lstcsproducts = new List <CustomerProductModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { customerProductModel.IsActive = true; customerProductModel.OrderID = customerProductModel.OrderID == null ? 0 : customerProductModel.OrderID; CustomerProduct customerProduct = null; if (customerProductModel.ProductID > 0) { customerProduct = GetCustomerProduct(db, customerProductModel.ProductID); } else { customerProduct = new CustomerProduct(); } customerProductModel.CopyProperties(customerProduct); if (customerProductModel.ProductID == 0) { db.CustomerProducts.Add(customerProduct); } db.SaveChanges(); var lstproducts = db.CustomerProducts.Where(m => m.OrderID == customerProductModel.OrderID && m.IsActive).ToList(); foreach (var cusprod in lstproducts) { CustomerProductModel objcsproduct = new CustomerProductModel(); cusprod.CopyProperties(objcsproduct); lstcsproducts.Add(objcsproduct); } return(lstcsproducts); } catch (Exception) { return(lstcsproducts); } } }
public List <CustomerProductModel> GetCurrentOrderProducts() { List <CustomerProductModel> lstcsproducts = new List <CustomerProductModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { var lstproducts = db.CustomerProducts.Where(m => m.OrderID == 0).ToList(); foreach (var cusprod in lstproducts) { CustomerProductModel objcsproduct = new CustomerProductModel(); cusprod.CopyProperties(objcsproduct); lstcsproducts.Add(objcsproduct); } } catch (Exception) { } return(lstcsproducts); } }
public OrderModel GetOrder(long orderID) { OrderModel ordermodel = new OrderModel(); using (ShopDevEntities db = new ShopDevEntities()) { try { var order = db.Orders.Where(m => m.OrderId == orderID).FirstOrDefault(); var lstproducts = db.CustomerProducts.Where(m => m.OrderID == orderID).ToList(); List <CustomerProductModel> lstcsproducts = new List <CustomerProductModel>(); foreach (var cusprod in lstproducts) { CustomerProductModel objcsproduct = new CustomerProductModel(); cusprod.CopyProperties(objcsproduct); lstcsproducts.Add(objcsproduct); } ordermodel.OrderId = order.OrderId; ordermodel.CustomerName = order.CustomerName; ordermodel.CustomerAddress = order.CustomerAddress; ordermodel.BookingAmount = order.BookingAmount; ordermodel.OrderDate = order.OrderDate; ordermodel.DeliveryDate = order.DeliveryDate; ordermodel.IsDelevered = order.IsDelevered; ordermodel.GRate = order.GRate; ordermodel.SRate = order.SRate; ordermodel.OrderStatus = order.OrderStatus; ordermodel.OutstandingAmount = order.OutstandingAmount; ordermodel.lstcusProduct = new List <CustomerProductModel>(); ordermodel.lstcusProduct.AddRange(lstcsproducts); } catch (Exception) { } } return(ordermodel); }
public List <CustomerProductModel> UpdateCustomerProduct(CustomerProductModel customerProductModel) { throw new NotImplementedException(); }