private void InitRepos() { this.productsRepo = new ProductsRepo(); this.unitsRepo = new UnitsRepo(); this.categoriesRepo = new CategoriesRepo(); this.unitsContentsRepo = new UnitsContentsRepo(); }
public void Start() { this.dgv_sales.DoubleBuffered(true); this.repo = new SalesRepo(); this.productsRepo = new ProductsRepo(); this.lbl_work_day.Text = this.date_picker_work_day.Value.ToString("ddd") + " " + this.date_picker_work_day.Value.ToString("yyyy/M/d"); this.WorkDay = this.date_picker_work_day.Value.ToString("yyyyMMdd"); this.lbl_day_total.Text = "0"; this.timer.Interval = 10; this.timer.Tick += this.TimerTick; this.timer.Start(); this.date_picker_work_day.Value = DateTime.Now.Date; this.viewWorkDaySales(); this.dgv_sales.CellValueChanged += this.dgv_sales_CellValueChanged; using (CategoriesRepo categoriesRepo = new CategoriesRepo()) { this.combo_category_name.DataSource = categoriesRepo.GetCategories(); } this.combo_category_name.SelectedValueChanged += this.combo_category_name_SelectedValueChanged; this.combo_category_name_SelectedValueChanged(this.combo_category_name, EventArgs.Empty); this.combo_product_name.SelectedValueChanged += this.combo_product_name_SelectedValueChanged; this.combo_product_name_SelectedValueChanged(this.combo_product_name, EventArgs.Empty); }
public Dto.Product GetBySku(int sku) { Model.Product product = ProductsRepo.GetBySku(sku); product.inventory.quantity = product.inventory.warehouses.Sum(a => a.quantity); product.isMarketable = product.inventory.quantity > 0; return(Mapper.Map <Dto.Product>(product)); }
public IActionResult Update(int id, [FromBody] Dto.UpdateProduct productDto) { var product = ProductsRepo.GetById(id); Mapper.Map(productDto, product); ProductsRepo.Update(product); return(Ok()); }
public void GetProductsTest() { ProductsRepo myProduct = new ProductsRepo(); var products = myProduct.GetProducts(); Assert.AreEqual("Laminate", products[1].ProductType); Assert.AreEqual(1.75, products[1].CostPerSqFoot); Assert.AreEqual(4.15, products[2].LaborCostPerSqFoot); Assert.AreEqual("Wood", products[3].ProductType); }
public void AddOrder(DateTime userDate, string userName, string userAbbreviation, string userProdType, string userArea) { ProductsRepo pRepo = new ProductsRepo(); TaxesRepo tRepo = new TaxesRepo(); OrderInfo ord = new OrderInfo(); ord.StateTax = new Taxes(); ord.OrderProduct = pRepo.GetProduct(userProdType); ord.StateTax = tRepo.GetStateTax(userAbbreviation); ord.OrderDate = userDate; ord.CustomerName = userName; ord.StateTax.StateAbbreviation = userAbbreviation;//todo validate ord.OrderProduct.ProductType = userProdType; ord.Area = decimal.Parse(userArea); string fileName = $"Orders_{ord.OrderDate.ToString("MMddyyyy")}.txt"; string file = dirPath + fileName; if (!File.Exists(file)) { ord.OrderNumber = 1; using (StreamWriter sw = File.CreateText(file)) { sw.WriteLine("OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LaborCostPerSquareFoot,MaterialCost,LaborCost,Tax,Total"); //add headers } } else { var list = _orderRepo.LoadOrders(userDate); ord.OrderNumber = list.Max(l => l.OrderNumber) + 1; //using (StreamReader sr = new StreamReader(file)) //{ // //sr.ReadLine(); // string line; // int counter = 0; // while ((line = sr.ReadLine()) != null) // { // counter++; // } // ord.OrderNumber = counter; //} } using (StreamWriter sw = File.AppendText(file)) { sw.WriteLine($"{ord.OrderNumber},{ord.CustomerName},{ord.StateTax.StateAbbreviation},{ord.StateTax.TaxRate},{ord.OrderProduct.ProductType},{ord.Area},{ord.OrderProduct.CostPerSquareFoot},{ord.OrderProduct.CostPerSquareFoot},{ord.OrderProduct.LaborCostPerSquareFoot},{ord.MaterialCost},{ord.LaborCost},{ord.Tax},{ord.Total}"); } }
Product GetSelectedProduct() { Product selectedProduct = null; var selectedItem = lsbProducts.SelectedItem; if (selectedItem != null) { int selectedProductId = Convert.ToInt32(selectedItem.Value); selectedProduct = new ProductsRepo().GetProduct(selectedProductId); } return(selectedProduct); }
public override void OnActionExecuting(ActionExecutingContext context) { base.OnActionExecuting(context); ProductsRepo.ChainQueryable(q => q.Include(p => p.Seller)); OrdersRepo.ChainQueryable(q => q .Include(o => o.Buyer) .Include(o => o.Products) .ThenInclude(p => p.Product.Seller.Address) .Include(o => o.Products) .ThenInclude(p => p.Product.Categories) .ThenInclude(c => c.Category.Parent) ); }
public IActionResult Create(int id, [FromBody] Dto.UpdateProduct newProductDto) { var newProduct = new Model.Product(id); Mapper.Map(newProductDto, newProduct); ProductsRepo.Create(newProduct); var createdProduct = ProductsRepo.GetById(id); Logger.LogInformation("New product was created: {@product}", createdProduct); return(Created($"{id}", Mapper.Map <Dto.Product>(createdProduct))); }
public ActionResult AllProducts() { try { ProductsRepo Productrepo = new ProductsRepo(); List <TblProduct> Productslist = Productrepo.getProductslist(); ViewBag.Productslist = Productslist; } catch (Exception ex) { ExceptionLog.WriteException(ex, "POSController", "AllProducts"); } return(View()); }
public TestApiController() { controller = new ApiController(); _catalogs = new CatalogsService(); _products = new ProductsSerice(); _cRepo = new CatalogRepo(); _pRepo = new ProductsRepo(); _testCatalog = new Catalog { Name = "Тест" }; _testProduct = new Product { Name = "Тест", CatalogId = 1, Price = 0, Quantity = 0 }; }
public ActionResult Product() { try { ProductsRepo Pro = new ProductsRepo(); ViewBag.AceCatList = Pro.getAceProductsCategorylist(); ViewBag.DxCatList = Pro.getDxProductsCategorylist(); } catch (Exception ex) { ExceptionLog.WriteException(ex, "POSController", "AllProducts"); } return(View()); }
public IActionResult Get() { if (Request != null && Request.Query.ContainsKey("unused")) { bool unused = Request.Query["unused"].ToString() == "y"; if (unused) { return(Ok(new ProductsRepo().GetUnused())); } } //filter and sort args bool active = false; if (Request != null && Request.Query.ContainsKey("active")) { active = Request.Query["active"].ToString() == "y"; } bool sort = false; if (Request != null && Request.Query.ContainsKey("sbh")) { sort = Request.Query["sbh"].ToString() == "true"; } List <Product> newProds = new ProductsRepo().GetAll(active ? 120 : -1); try { if (sort) { newProds.Sort(); } else { newProds.Sort(new Sorter()); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); } return(Ok(newProds)); }
public void Start() { if (this.repo == null) { this.repo = new PurchasesRepo(); this.productsRepo = new ProductsRepo(); this.dgv_purchases.DoubleBuffered(true); using (CategoriesRepo categoriesRepo = new CategoriesRepo()) { this.combo_category_name.DataSource = categoriesRepo.GetCategories(); } this.combo_category_name.SelectedIndexChanged += this.combo_category_name_SelectedIndexChanged; this.combo_category_name_SelectedIndexChanged(this.combo_category_name, EventArgs.Empty); this.combo_unit_name.SelectedIndexChanged += this.combo_unit_name_SelectedIndexChanged; this.combo_years.DataSource = this.repo.GetYears().ColumnToArray(0); } }
private async Task <OrderEntity> TransposeCartToOrder(IList <CartItemViewModel> cart) { await ValidateCart(cart); var productIds = cart.Select(ci => ci.Product.Id); var products = (await ProductsRepo.FindAll(p => productIds.Any(id => id == p.Id))).ToList(); var ops = (from cartItem in cart let product = products.First(p => p.Id == cartItem.Product.Id) select new OrderProductEntity { Product = product, UnitPrice = product.Price, Unit = product.Unit, Quantity = cartItem.Quantity }) .ToList(); return(new OrderEntity { Buyer = CurrentBuyerProfile, TotalPrice = ops.Sum(op => op.Quantity * op.UnitPrice), Products = ops }); }
public Response FetchProductInfo(string ProductType) { var response = new Response(); var productsRepo = new ProductsRepo(); var product = productsRepo.GetProductInfo(ProductType); if (product == null) { response.Success = false; response.Message = "That product is not in our database."; } else { response.Success = true; response.ProductInfo = product; } return(response); }
public async Task <System.Net.Http.HttpResponseMessage> PutFile(int id, string resource) { string username = ""; if (HttpContext != null && HttpContext.Request != null) { username = ProductsController.getUsername(HttpContext.Request.Headers["Authorization"]); } if (string.IsNullOrEmpty(username)) { username = ProductsController.getUsername2(HttpContext.Request.Headers["Cookie"]); } if (username != Startup.Configuration["adminUser"]) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } int index = resource.IndexOf('/'); string profileName = resource.Substring(index + 1); string filename = String.Format("log-{0}.txt", profileName); if (Request != null && Request.Query.ContainsKey("filename")) { filename = Request.Query["filename"].ToString(); } bool append = false; if (Request != null && Request.Query.ContainsKey("append")) { append = Request.Query["append"].ToString() == "true"; } ProductsRepo repo = new ProductsRepo(); if (repo.GetOne(id) == null) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } bool history = repo.GetOne(id).UploadHistory; if (filename.EndsWith(".zip")) { history = false; } try { string body = ""; using (var reader = new StreamReader(Request.Body)) { body = await reader.ReadToEndAsync(); } StringReader sr = new StringReader(body); System.Net.Mail.MailMessage mm = Amende.Snorre.MailMessageMimeParser.ParseMessage(sr); string datedir = DateTime.Now.ToString("MMddyyyy"); System.IO.Directory.CreateDirectory("tmp/" + id); if (history) { System.IO.Directory.CreateDirectory("tmp/" + id + "/" + datedir); } Console.WriteLine("count=" + mm.Attachments.Count); if (mm.Attachments.Count > 0) { using (var fileStream = System.IO.File.Open(String.Format(@"{0}/{1}/{2}", "tmp", id, filename), append ? FileMode.Append : FileMode.Create)) { using (MemoryStream ms = new MemoryStream()) { mm.Attachments[0].ContentStream.CopyTo(ms); ms.Position = 0; ms.CopyTo(fileStream); if (append || !checkHash(ms, id, filename)) { history = false; //System.Console.WriteLine("dup hash for " + filename); } } } if (history) { System.IO.File.Copy(String.Format(@"{0}/{1}/{2}", "tmp", id, filename), String.Format(@"{0}/{1}/{2}/{3}_{4}", "tmp", id, datedir, DateTime.Now.Ticks, filename)); } System.IO.Directory.CreateDirectory("wwwroot/WebApp/logs/" + id); System.IO.File.WriteAllText("wwwroot/WebApp/logs/" + id + "/" + filename + "_date.txt", DateTime.Now.ToString()); } else { using (StreamWriter sw = System.IO.File.CreateText("tmp/" + id + "/" + filename)) { sw.Write(mm.Body); } } } catch (Exception ex) { Console.WriteLine("exception" + ex.Message); } return(new HttpResponseMessage(HttpStatusCode.Created)); }
public Dto.Product GetById(int id) { return(Mapper.Map <Dto.Product>(ProductsRepo.GetById(id))); }
public SettingPrices() { this.InitializeComponent(); this.repo = new ProductsRepo(); }
public List <Product> FetchProductsList() { var productsRepo = new ProductsRepo(); return(productsRepo.GetProductsList()); }
public ProductsController(ProductsDB db) { _repo = new ProductsRepo(db); }
public ActionResult SaveProduct(FormCollection FC) { ProductsRepo Repo = new ProductsRepo(); string DxCat = ""; string DxSP = ""; string DxLD = ""; string DxSD = ""; string AceCat = ""; string AceSP = ""; string AceLD = ""; string AceSD = ""; string BNCCat = ""; string BNCSP = ""; string BNCLD = ""; string BNCSD = ""; var ProName = FC["ProName"]; var ProSalePrice = FC["ProSalePrice"]; var IsActive = FC["IsActive"]; var DermicsCheckbox = FC["DermicsCheckbox"]; var AceCheckbox = FC["AceCheckbox"]; var BNCCheckbox = FC["BNCCheckbox"]; if (ProName == null) { TempData["RequiredValues"] = "ProName"; return(RedirectToAction("Product")); } if (ProSalePrice == null) { TempData["RequiredValues"] = "ProSalePrice"; return(RedirectToAction("Product")); } if (DermicsCheckbox == "true") { var DermicsCategory = FC["DermicsCategory"]; var DermicsSalePrice = FC["DermicsSalePrice"]; var DermicsLongDescription = FC["editor1"]; var DermicsShortDescription = FC["DermicsShortDescription"]; if (DermicsCategory == "0") { TempData["RequiredValues"] = "DermicsCategory"; return(RedirectToAction("Product")); } else { DxCat = DermicsCategory; } if (DermicsSalePrice == null) { TempData["RequiredValues"] = "DermicsSalePrice"; return(RedirectToAction("Product")); } else { DxSP = DermicsSalePrice; } if (DermicsLongDescription == null) { TempData["RequiredValues"] = "DermicsLongDescription"; return(RedirectToAction("Product")); } else { DxLD = DermicsLongDescription; } if (DermicsShortDescription == null) { TempData["RequiredValues"] = "DermicsShortDescription"; return(RedirectToAction("Product")); } else { DxSD = DermicsShortDescription; } } if (AceCheckbox == "true") { var AceCategory = FC["AceCategory"]; var AceSalePrice = FC["AceSalePrice"]; var AceLongDescription = FC["editor2"]; var AceShortDescription = FC["AceShortDescription"]; if (AceCategory == "0") { TempData["RequiredValues"] = "AceCategory"; return(RedirectToAction("Product")); } else { AceCat = AceCategory; } if (AceSalePrice == null) { TempData["RequiredValues"] = "AceSalePrice"; return(RedirectToAction("Product")); } else { AceSP = AceSalePrice; } if (AceLongDescription == null) { TempData["RequiredValues"] = "AceLongDescription"; return(RedirectToAction("Product")); } else { AceLD = AceLongDescription; } if (AceShortDescription == null) { TempData["RequiredValues"] = "AceShortDescription"; return(RedirectToAction("Product")); } else { AceSD = AceShortDescription; } } if (BNCCheckbox == "true") { var BNCCategory = FC["BNCCategory"]; var BNCSalePrice = FC["BNCSalePrice"]; var BNCLongDescription = FC["editor3"]; var BNCShortDescription = FC["BNCShortDescription"]; if (BNCCategory == "0") { TempData["RequiredValues"] = "BNCCategory"; return(RedirectToAction("Product")); } else { BNCCat = BNCCategory; } if (BNCSalePrice == null) { TempData["RequiredValues"] = "BNCSalePrice"; return(RedirectToAction("Product")); } else { BNCSP = BNCSalePrice; } if (BNCLongDescription == null) { TempData["RequiredValues"] = "BNCLongDescription"; return(RedirectToAction("Product")); } else { BNCLD = BNCLongDescription; } if (BNCShortDescription == null) { TempData["RequiredValues"] = "BNCShortDescription"; return(RedirectToAction("Product")); } else { BNCSD = BNCShortDescription; } } var DermicsDiscountedPrice = FC["DermicsDiscountedPrice"]; var DermicsFamilyName = FC["DermicsFamilyName"]; var DermicsYoutubeLink = FC["DermicsYoutubeLink"]; var DermicsIsActive = FC["DermicsIsActive"]; var AceDiscountedPrice = FC["AceDiscountedPrice"]; var AceFamilyName = FC["AceFamilyName"]; var AceYoutubeLink = FC["AceYoutubeLink"]; var AceIsActive = FC["AceIsActive"]; var BNCDiscountedPrice = FC["BNCDiscountedPrice"]; var BNCFamilyName = FC["BNCFamilyName"]; var BNCYoutubeLink = FC["BNCYoutubeLink"]; var BNCIsActive = FC["BNCIsActive"]; //Repo.SaveProduct(); return(RedirectToAction("Product")); }
public IActionResult Put(int id, [FromBody] Product p) { bool update = false; if (Request != null && Request.Query.ContainsKey("update")) { update = Request.Query["update"].ToString() == "true"; } bool uploadhist = false; if (Request != null && Request.Query.ContainsKey("uploadhist")) { uploadhist = Request.Query["uploadhist"].ToString() == "true"; } string username = ""; if (HttpContext != null && HttpContext.Request != null) { username = getUsername(HttpContext.Request.Headers["Authorization"]); } if (string.IsNullOrEmpty(username)) { username = getUsername2(HttpContext.Request.Headers["Cookie"]); } if (username == Startup.Configuration["readonlyUser"] && (string.IsNullOrEmpty(p.Command) || p.Command != "getProperties") ) { return(Unauthorized()); } if (!string.IsNullOrEmpty(p.Command)) { System.Console.WriteLine(p.Command); } ProductsRepo repo = new ProductsRepo(); if (repo.GetOne(id) == null) { return(NotFound(p)); } string ret = "good"; repo.SetOne(id, p, HttpContext.Connection.RemoteIpAddress.ToString()); Product product = repo.GetOne(id); //TODO: use set method instead of updating product if (update) { bool doSave = p.Version != product.Version; if (string.IsNullOrEmpty(p.Status)) { product.Percent = p.Percent; product.IP = p.IP; } product.Version = p.Version; product.OS = p.OS; product.Profile = p.Profile; if (doSave) { repo.Save(); } } else if (!string.IsNullOrEmpty(p.Command)) { //increment the cmd number if (string.IsNullOrEmpty(product.Command) || !product.Command.Contains(":")) { product.Command = "1:" + p.Command; } else { int i = 1 + System.Convert.ToInt32(product.Command.Substring(0, product.Command.IndexOf(':'))); product.Command = i.ToString() + ":" + p.Command; } ret = product.Command; //don't update lastReport time if received command from UI return(Ok(product)); } else if (!string.IsNullOrEmpty(p.Response)) { product.Response = p.Response; } else if (!string.IsNullOrEmpty(p.Output)) { product.setOutput(p.Output); } else if (!string.IsNullOrEmpty(p.Desc)) { product.Desc = p.Desc; repo.Save(); } else if (!string.IsNullOrEmpty(p.Name)) { if (username != Startup.Configuration["adminUser"]) { return(Unauthorized()); } product.Name = p.Name; writeIds(); } else if (uploadhist) { Console.WriteLine("UploadHistory " + p.UploadHistory); product.UploadHistory = p.UploadHistory; //repo.Save(); } else { product.Percent = p.Percent; } product.IP2 = HttpContext.Connection.RemoteIpAddress.ToString(); product.LastReport = DateTime.Now; string ip = GetHeaderValueAs <string>("X-Forwarded-For"); //Console.WriteLine("forwarded from "+ip); if (!string.IsNullOrEmpty(ip)) { product.IP2 = ip; } repo.AddOne(0, new Product() { Id = 0, Name = "" }); Product product0 = repo.GetOne(0); if (product0 != null) { product0.LastReport = DateTime.Now; } //must return existing product NOT incoming product, so that we're returning latest command return(Ok(product)); }
public void Start() { this.repo = new ProductsRepo(); this.dgv_store.DataSource = this.repo.GetAllProducts(); }
public FormAllCategoryProducts() { this.InitializeComponent(); this.productsRepo = new ProductsRepo(); this.categoriesRepo = new CategoriesRepo(); }
public IActionResult Delete(int id) { ProductsRepo.Delete(id); return(Ok()); }
public ProductsController() { ProductsRepo = new ProductsRepo(); }
public IEnumerable <Dto.Product> Get() { return(ProductsRepo.Get().Select(Mapper.Map <Dto.Product>)); }
public IActionResult Get(int id) { // foreach (var v in HttpContext.Request.Headers) // System.Console.WriteLine(v.Key); if (id == 0) { int freespace = 0; int freespace2 = 0; DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { //System.Console.WriteLine(d.Name + "=" + d.AvailableFreeSpace); if (d.Name == "/") { freespace = (int)(d.AvailableFreeSpace / (1024 * 1024)); } string drive = Startup.Configuration["altDriveForSize"]; if (!string.IsNullOrEmpty(drive) && d.Name == drive) { freespace2 = (int)(d.AvailableFreeSpace / (1024 * 1024)); } } string username = ""; if (HttpContext != null && HttpContext.Request != null) { username = getUsername(HttpContext.Request.Headers["Authorization"]); } if (string.IsNullOrEmpty(username)) { username = getUsername2(HttpContext.Request.Headers["Cookie"]); } //foreach (var head in HttpContext.Request.Headers) // System.Console.WriteLine(head); bool isAdmin = username == Startup.Configuration["adminUser"]; string release = "Unknown"; if (System.IO.File.Exists(@"/etc/os-release")) { release = System.IO.File.ReadAllText(@"/etc/os-release"); int index1 = release.IndexOf("\nID="); if (index1 != -1) { release = release.Substring(index1 + 4); } index1 = release.IndexOf("\n"); if (index1 != -1) { release = release.Substring(0, index1); } } return(Ok(new Product() { Id = 0, Name = username, Status = isAdmin.ToString(), OS = release, Version = Startup.Configuration["version"], Percent = freespace, Age = freespace2, IP = doPolling ? "from " + Startup.Configuration["pollingIP"] : "", AlertCondition = doPolling })); } Console.WriteLine(string.Format("Get({0})", id)); Product prod = new ProductsRepo().GetOne(id); if (prod == null) { return(NotFound(id)); } return(Ok(prod)); }
public ProductsController(ProductsRepo repo) { _repo = repo; }