public PartialViewResult LoadProduct(int?CommissionCusId) { var model = new CommissionCusViewModel(); model.DetailList = new List <CommisionCustomerViewModel>(); model.ProductList = new List <ProductViewModel>(); //lấy danh sách chi tiết chiết khấu sản phẩm if (CommissionCusId != null && CommissionCusId.Value > 0) { var detail = CommissionDetailRepository.GetAllCommisionCustomer().Where(x => x.CommissionCusId == CommissionCusId).ToList(); model.DetailList = detail.Select(x => new CommisionCustomerViewModel { ProductId = x.ProductId.Value, Id = x.Id, IsMoney = x.IsMoney, Type = x.Type, CommissionValue = x.CommissionValue, CommissionCusId = x.CommissionCusId.Value }).ToList(); } //lấy danh sách sản phẩm thuộc nhóm đã chọn var product = productRepository.GetAllProduct(); model.ProductList = product.Select(x => new ProductViewModel { Id = x.Id, Code = x.Code, Name = x.Name, PriceOutbound = x.PriceOutbound }).ToList(); return(PartialView(model)); }
public ViewResult Create() { var model = new PromotionViewModel(); var productList = ProductRepository.GetAllProduct() .Select(item => new ProductViewModel { Code = item.Code, Barcode = item.Barcode, Name = item.Name, Id = item.Id, CategoryCode = item.CategoryCode, PriceOutbound = item.PriceOutbound, Unit = item.Unit, Type = item.Type }); ViewBag.productList = productList; return(View(model)); }
public ActionResult CheckCodeExsist(int?id, string code) { code = code.Trim(); var product = productRepository.GetAllProduct() .Where(item => item.Code == code).FirstOrDefault(); if (product != null) { if (id == null || (id != null && product.Id != id)) { return(Content("Trùng mã sản phẩm!")); } else { return(Content("")); } } else { return(Content("")); } }
public JsonResult GetListProductJsonBySupplierId(int?supplierId) { if (supplierId == null) { return(Json(new List <int>(), JsonRequestBehavior.AllowGet)); } var supplier = SupplierRepository.GetSupplierById(supplierId.Value); if (supplier != null) { supplier.ProductIdOfSupplier = "," + supplier.ProductIdOfSupplier + ","; var list = ProductRepository.GetAllProduct().AsEnumerable().Where(x => supplier.ProductIdOfSupplier.Contains("," + x.Id + ",") == true); return(Json(list.Select(x => new { Id = x.Id, Name = x.Name, Price = x.PriceInbound, Unit = x.Unit }), JsonRequestBehavior.AllowGet)); } return(Json(new List <int>(), JsonRequestBehavior.AllowGet)); }
public ActionResult Create(int?Id) { RequestInboundViewModel model = new RequestInboundViewModel(); model.DetailList = new List <RequestInboundDetailViewModel>(); if (Id.HasValue && Id > 0) { var requestInbound = RequestInboundRepository.GetvwRequestInboundById(Id.Value); AutoMapper.Mapper.Map(requestInbound, model); var detailList = RequestInboundRepository.GetAllvwRequestInboundDetailsByInvoiceId(requestInbound.Id).ToList(); AutoMapper.Mapper.Map(detailList, model.DetailList); } var warehouseList = WarehouseRepository.GetvwAllWarehouse().AsEnumerable(); var user = userRepository.GetByvwUserName(Helpers.Common.CurrentUser.UserName); if (!Erp.BackOffice.Filters.SecurityFilter.IsAdmin() && !Erp.BackOffice.Filters.SecurityFilter.IsKeToan()) { warehouseList = warehouseList.Where(x => ("," + user.WarehouseId + ",").Contains("," + x.Id + ",") == true); } var _warehouseList = warehouseList.Select(item => new SelectListItem { Text = item.Name + " (" + item.BranchName + ")", Value = item.Id.ToString() }); ViewBag.warehouseList = _warehouseList; //string image_folder_product = Helpers.Common.GetSetting("product-image-folder"); var productList = ProductRepository.GetAllProduct().AsEnumerable() .Select(item => new ProductViewModel { Code = item.Code, Barcode = item.Barcode, Name = item.Name, Id = item.Id, CategoryCode = string.IsNullOrEmpty(item.CategoryCode) ? "Sản phẩm khác" : item.CategoryCode, PriceOutbound = item.PriceOutbound, Unit = item.Unit, Image_Name = Erp.BackOffice.Helpers.Common.KiemTraTonTaiHinhAnh(item.Image_Name, "product-image-folder", "product") }).ToList(); ViewBag.productList = productList; model.CreatedDate = DateTime.Now; model.CreatedUserName = Helpers.Common.CurrentUser.FullName; ViewBag.isAdmin = Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId == 1 ? true : false; if (model.DetailList != null && model.DetailList.Count > 0) { foreach (var item in model.DetailList) { var product = productList.Where(i => i.Id == item.ProductId).FirstOrDefault(); if (product == null) { item.Id = 0; } } model.DetailList.RemoveAll(x => x.Id == 0); int n = 0; foreach (var item in model.DetailList) { item.OrderNo = n; n++; } } return(View(model)); }