private void bindDropDownList() { List <CategoryLookup> jokeCat = CategoriesFactory.Create(); ddlJokeCategories.DataSource = jokeCat; ddlJokeCategories.DataBind(); }
public SBInventoryBaseController() { _seasonFactory = new SeasonFactory(); _categoryFactory = new CategoriesFactory(); _printerFactory = new PrinterFactory(); _categoryFactoryInte = new InteCategoriesFactory(); }
public SBInventoryCategoriesController() { _factory = new CategoriesFactory(); _productTypeFactory = new ProductTypeFactory(); //================ ViewBag.ListStore = GetListStore(); }
public HttpStatusCode CreateCategory(CreateCategoryDto createCategoryDto, string userId) { Category category = CategoriesFactory.CategoryToDbo(createCategoryDto); Catalog catalog = _ctx.Catalogs.FirstOrDefault(f => f.Id == createCategoryDto.CatalogId); category.Catalog = catalog; category.CatalogId = catalog.Id; ApplicationUser user = _ctx.Users.FirstOrDefault(f => f.Id == userId); category.User = user; category.UserId = user.Id; try { _ctx.Categories.Add(category); _ctx.SaveChanges(); return(HttpStatusCode.OK); } catch (Exception ex) { return(HttpStatusCode.InternalServerError); } }
public PartialViewResult Edit(string Id) { var model = GetDetail(Id); CategoriesFactory _cateFactory = new CategoriesFactory(); var _categories = _cateFactory.GetListCategory(CurrentUser.UserId); //Can not change category has different type with the old category. int curCateType = _categories.Where(w => w.Id == model.CategoryId).Select(s => s.Type).FirstOrDefault(); var lstCategories = new List <SelectListItem>(); lstCategories = _categories.Where(x => x.IsActive && x.Type == curCateType && x.Id != model.CategoryId) .Select(x => new SelectListItem { Value = x.Id, Text = x.Name }) .ToList(); lstCategories.Add(new SelectListItem { Value = model.CategoryId, Text = model.CategoryName }); model.Categories = lstCategories; return(PartialView("_Edit", model)); }
public CategoryViewModel GetCategoryById(int categoryId) { Category category = _ctx.Categories.FirstOrDefault(f => f.Id == categoryId); Catalog catalog = _ctx.Catalogs.FirstOrDefault(f => f.Id == category.CatalogId); ApplicationUser user = _ctx.Users.FirstOrDefault(f => f.Id == category.UserId); return(CategoriesFactory.CategoryToViewModel(category, catalog.Name, user.UserName)); }
// GET: SBInventoryModifier public SBInventoryModifierInteController() { _factory = new InteProductFactory(); _seasonFactory = new SeasonFactory(); _categoryFactory = new CategoriesFactory(); _tipServiceChargeFactory = new TipServiceChargeFactory(); //ViewBag.ListStore = GetListStoreIntegration(); }
public List <CategoryViewModel> GetAllCategories() { List <Category> categories = _ctx.Categories.ToList(); List <CategoryViewModel> categoriesViewModel = new List <CategoryViewModel>(); categories.ForEach(category => { Catalog catalog = _ctx.Catalogs.FirstOrDefault(f => f.Id == category.CatalogId); ApplicationUser user = _ctx.Users.FirstOrDefault(f => f.Id == category.UserId); categoriesViewModel.Add(CategoriesFactory.CategoryToViewModel(category, catalog.Name, user.UserName)); }); return(categoriesViewModel); }
public ActionResult Create() { ProductDetailModels model = new ProductDetailModels(); try { var _user = Session["User"] as UserSession; if (_user == null) { return(RedirectToAction("Index", "Login", new { area = "" })); } else { CategoriesFactory _cateFactory = new CategoriesFactory(); var lstCategory = _cateFactory.GetListCategory(_user.UserId); lstCategory = lstCategory.OrderBy(o => o.Name).ThenBy(o => o.Id).ToList(); var _categories = lstCategory .Where(x => x.IsActive) .Select(x => new SelectListItem { Value = x.Id, Text = x.Name }) .ToList(); model.Categories = _categories; var Type = lstCategory != null?lstCategory.Where(x => x.IsActive).FirstOrDefault().Type : 0; var lstFunction = _factory.GetProductFunctions(Type).OrderBy(o => o.Name).Select(x => new ProductFunctionModels { FunctionID = x.ID, FunctionName = x.Name, IsDefault = x.IsDefault, IsSelected = x.IsDefault ? true : false }) .ToList(); model.ListFunction = lstFunction; } } catch (Exception ex) { NSLog.Logger.Error("Create: ", ex); } return(View(model)); }
public ActionResult LoadFunction(string CategoryId) { try { CategoriesFactory _cateFactory = new CategoriesFactory(); var Type = _cateFactory.GetDetail(CategoryId).Type; var lstFunction = _factory.GetProductFunctions(Type).Select(x => new ProductFunctionModels { FunctionID = x.ID, FunctionName = x.Name, IsDefault = x.IsDefault, IsSelected = x.IsDefault ? true : false }).ToList(); lstFunction = lstFunction.OrderBy(x => x.FunctionName).ToList(); return(PartialView("_ItemFunctions", lstFunction)); } catch (Exception ex) { NSLog.Logger.Error("LoadFunction Error", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public SBInventoryCategoriesController() { _factory = new CategoriesFactory(); }
public MTListofProductFeaturesController() { _factory = new ListofProductFeaturesFactory(); _categoryfacetory = new CategoriesFactory(); ViewBag.ListCategory = _factory.GetListCategory(CurrentUser.UserId); }
public ActionResult Edit(ProductDetailModels model) { string _CurrentURL = model.ImageURL; try { CategoriesFactory _cateFactory = new CategoriesFactory(); //var _categories = _cateFactory.GetListCategory(CurrentUser.UserId) // .Where(x => x.IsActive) // .Select(x => new SelectListItem // { // Value = x.Id, // Text = x.Name // }) // .ToList(); //model.Categories = _categories; var _categories = _cateFactory.GetListCategory(CurrentUser.UserId); //Can not change category has different type with the old category. int curCateType = _categories.Where(w => w.Id == model.CategoryId).Select(s => s.Type).FirstOrDefault(); var lstCategories = new List <SelectListItem>(); lstCategories = _categories.Where(x => x.IsActive && x.Type == curCateType && x.Id != model.CategoryId) .Select(x => new SelectListItem { Value = x.Id, Text = x.Name }) .ToList(); lstCategories.Add(new SelectListItem { Value = model.CategoryId, Text = model.CategoryName }); model.Categories = lstCategories; if (string.IsNullOrEmpty(model.Name)) { ModelState.AddModelError("Name", "The Name field is required"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (string.IsNullOrEmpty(model.Code)) { ModelState.AddModelError("Code", "The Code field is required"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (string.IsNullOrEmpty(model.CategoryId)) { ModelState.AddModelError("CategoryId", "The Category field is required"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (model.PictureUpload != null && !Commons.ImageExtendFiler.Contains(model.PictureUpload.ContentType)) { ModelState.AddModelError("PictureUpload", Commons.ErrorMsgFilterImage); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (model.SaleFrom > model.SaleTo) { ModelState.AddModelError("SaleFrom", "From Date must be less than To Date."); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (model.ListPrice == null || (model.ListPrice != null && model.ListPrice.Count == 0)) { ModelState.AddModelError("ListPrice", "The Price Items is required"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } //if (model.ListPrice != null && model.ListPrice.Count > 0) //{ // var isExistActive = model.ListPrice.Any(x => x.IsActive); // if (!isExistActive) // { // ModelState.AddModelError("ListPrice", "Please enter a price item greater than or equal to 1 is active"); // Response.StatusCode = (int)HttpStatusCode.BadRequest; // return PartialView("_Edit", model); // } //} //if (model.IsExtend && (model.ListPriceExtend == null ||(model.ListPriceExtend != null && model.ListPriceExtend.Count == 0))) //{ // ModelState.AddModelError("ListPriceExtend", "The Extend Price Items is requered"); // Response.StatusCode = (int)HttpStatusCode.BadRequest; // return PartialView("_Edit", model); //} if (!ModelState.IsValid) { if ((ModelState["PictureUpload"]) != null && (ModelState["PictureUpload"]).Errors.Count > 0) { model.ImageURL = ""; } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } if (string.IsNullOrEmpty(model.ImageURL)) { model.ImageURL = model.ImageURL.Replace(Commons.PublicImages, "").Replace(Commons.Image100_100, ""); } /*** Processing Image *****/ byte[] photoByte = null; if (model.PictureUpload != null && model.PictureUpload.ContentLength > 0) { Byte[] imgByte = new Byte[model.PictureUpload.ContentLength]; model.PictureUpload.InputStream.Read(imgByte, 0, model.PictureUpload.ContentLength); model.PictureByte = imgByte; model.ImageURL = Guid.NewGuid() + Path.GetExtension(model.PictureUpload.FileName); model.PictureUpload = null; photoByte = imgByte; } else { model.ImageURL = model.ImageURL.Replace(Commons.PublicImages, "").Replace(Commons.Image100_100, ""); } /*** End Processing Image ****/ string msg = ""; model.CreateUser = CurrentUser.UserId; model.ProductType = (int)Commons.EProductType.Product; if (model.ListCategory == null) { model.ListCategory = new List <ProductCategoryModels>(); } model.ListCategory.Add(new ProductCategoryModels { CategoryID = model.CategoryId }); model.ListPrice.AddRange(model.ListPriceExtend); model.ListPrice.Where(x => x.IsNew).ToList().ForEach(x => x.ID = null); var tmp = model.PictureByte; model.PictureByte = null; if (model.ListFunction != null && model.ListFunction.Count > 0) { model.ListFunction.Where(x => x.IsDefault).ToList().ForEach(x => x.IsSelected = true); } bool result = _factory.CreateOrEdit(model, ref msg); if (result) { model.PictureByte = tmp; if (!string.IsNullOrEmpty(model.ImageURL) && model.PictureByte != null) { var originalDirectory = new DirectoryInfo(string.Format("{0}Uploads\\", Server.MapPath(@"\"))); var path = string.Format("{0}{1}", originalDirectory, model.ImageURL); MemoryStream ms = new MemoryStream(photoByte, 0, photoByte.Length); ms.Write(photoByte, 0, photoByte.Length); System.Drawing.Image imageTmp = System.Drawing.Image.FromStream(ms, true); ImageHelper.Me.SaveCroppedImage(imageTmp, path, model.ImageURL, ref photoByte); model.PictureByte = photoByte; FTP.Upload(model.ImageURL, model.PictureByte); ImageHelper.Me.TryDeleteImageUpdated(path); } return(RedirectToAction("Index")); } else { //ModelState.AddModelError("Name", Commons.ErrorMsg); ModelState.AddModelError("Error", msg); model.ImageURL = _CurrentURL; model.ListPrice = model.ListPrice.Where(w => w.IsExtend == false).ToList(); model.ListPrice.Where(x => x.IsNew).ToList().ForEach(x => x.ID = Guid.NewGuid().ToString()); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } } catch (Exception ex) { NSLog.Logger.Error("Edit :", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public SBInventoryAdditionController() { _factory = new ProductFactory(); _facCate = new CategoriesFactory(); }
public SBInventoryDiscountController() { _factory = new DiscountFactory(); _facCate = new CategoriesFactory(); }
public ProductModels GetDetail(string id) { try { ProductModels model = _factory.GetProductDetail(id); if (model.ListGroup != null) { List <GroupProductModels> groupP = model.ListGroup; for (int i = 0; i < model.ListGroup.Count; i++) { model.ListGroup[i].OffSet = i; model.CurrencySymbol = CurrentUser.CurrencySymbol; if (model.ListGroup[i].ListProductOnGroup != null) { for (int j = 0; j < model.ListGroup[i].ListProductOnGroup.Count; j++) { model.ListGroup[i].ListProductOnGroup[j].OffSet = j; } } } } model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL; model.sServiceCharge = model.ServiceCharge == -1 ? "" : model.ServiceCharge.ToString(); //================Get Category CategoriesFactory categoryf = new CategoriesFactory(); //List<CategoriesModels> lstCg = categoryf.GetListCategory(model.StoreID, null, Commons.EProductType.SetMenu.ToString("d"), CurrentUser.ListOrganizationId); //SelectListItem sslItemCag = new SelectListItem(); //foreach (var category in lstCg) //{ // if (category.ListChild != null) // { // foreach (var item in category.ListChild) // { // sslItemCag = new SelectListItem(); // sslItemCag.Value = item.ID; // sslItemCag.Text = item.Name;// + " [" + item.StoreName + "]"; // sslItemCag.Selected = item.ID.Equals(model.CategoryID); // model.ListCategories.Add(sslItemCag); // } // } // else // { // sslItemCag = new SelectListItem(); // sslItemCag.Value = category.ID; // sslItemCag.Text = category.Name;//+ " [" + category.StoreName + "]"; // sslItemCag.Selected = category.ID.Equals(model.CategoryID); // model.ListCategories.Add(sslItemCag); // } //} // Updated 08282017 List <SBInventoryBaseCateGroupViewModel> lstCateGroup = categoryf.GetListCategorySortParent(model.StoreID, null, Commons.EProductType.SetMenu.ToString("d"), CurrentUser.ListOrganizationId, model.CategoryID); model.lstCateGroup = lstCateGroup; //=======TImeSlot model.ListSeason = GetListTimeSlot02(model.StoreID, model.ListProductSeason); if (model.ListProductSeason != null && model.ListProductSeason.Count != 0) { model.ProductSeason = string.Join(",", model.ListProductSeason.Select(x => x.SeasonName).ToList()); } else if (model.ListProductSeason.Count == 0) { model.ProductSeason = "All"; } //================Price SeasonFactory seasonf = new SeasonFactory(); List <SeasonModels> lstSs = seasonf.GetListSeason(model.StoreID, null, CurrentUser.ListOrganizationId); List <SelectListItem> lstSllItemSeason = new List <SelectListItem>(); SelectListItem sslItemSeason; foreach (var season in lstSs) { sslItemSeason = new SelectListItem(); sslItemSeason.Value = season.ID; sslItemSeason.Text = season.Name;// + " [" + season.StoreName + "]"; sslItemSeason.Selected = season.ID.Equals(model.SeasonPriceID); lstSllItemSeason.Add(sslItemSeason); } foreach (PriceItem priceItem in model.ListPrices) { priceItem.ListSeasons = lstSllItemSeason; } model.ListPrices[0].Price = model.DefaultPrice; model.ListPrices[1].Price = model.SeasonPrice == -1 ? 0 : model.SeasonPrice; model.ListPrices[1].SeasonID = model.SeasonPriceID; return(model); } catch (Exception ex) { _logger.Error("Product_SetMenu_Detail: " + ex); return(null); } }
public ProductModels GetDetail(string id) { try { ProductModels model = _factory.GetProductDetail(id); model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL; model.sServiceCharge = model.ServiceCharge == -1 ? "" : model.ServiceCharge.ToString(); //================Get Category CategoriesFactory categoryf = new CategoriesFactory(); //List<CategoriesModels> lstCg = categoryf.GetListCategory(model.StoreID, null, Commons.EProductType.Modifier.ToString("d"), CurrentUser.ListOrganizationId); //SelectListItem sslItemCag; //foreach (var category in lstCg) //{ // if (category.ListChild != null) // { // foreach (var item in category.ListChild) // { // sslItemCag = new SelectListItem(); // sslItemCag.Value = item.ID; // sslItemCag.Text = item.Name;// + " [" + item.StoreName + "]"; // sslItemCag.Selected = item.ID.Equals(model.CategoryID); // model.ListCategories.Add(sslItemCag); // } // } // else // { // sslItemCag = new SelectListItem(); // sslItemCag.Value = category.ID; // sslItemCag.Text = category.Name;// + " [" + category.StoreName + "]"; // sslItemCag.Selected = category.ID.Equals(model.CategoryID); // model.ListCategories.Add(sslItemCag); // } //} // Updated 08282017 List <SBInventoryBaseCateGroupViewModel> lstCateGroup = categoryf.GetListCategorySortParent(model.StoreID, null, Commons.EProductType.Modifier.ToString("d"), CurrentUser.ListOrganizationId, model.CategoryID); model.lstCateGroup = lstCateGroup; //================Price/Season SeasonFactory seasonf = new SeasonFactory(); List <SeasonModels> lstSs = seasonf.GetListSeason(model.StoreID, null, CurrentUser.ListOrganizationId); List <SelectListItem> lstSllItemSeason = new List <SelectListItem>(); SelectListItem sslItemSeason; foreach (var season in lstSs) { sslItemSeason = new SelectListItem(); sslItemSeason.Value = season.ID; sslItemSeason.Text = season.Name;// + " [" + season.StoreName + "]"; sslItemSeason.Selected = season.ID.Equals(model.SeasonPriceID); lstSllItemSeason.Add(sslItemSeason); } foreach (PriceItem priceItem in model.ListPrices) { priceItem.ListSeasons = lstSllItemSeason; } model.ListPrices[0].Price = model.DefaultPrice; model.ListPrices[1].Price = model.SeasonPrice == -1 ? 0 : model.SeasonPrice; model.ListPrices[1].SeasonID = model.SeasonPriceID; return(model); } catch (Exception ex) { _logger.Error("Product_Modifier_Detail: " + ex); return(null); } }
public ListofProductFeaturesFactory() { _categoryfacetory = new CategoriesFactory(); }