// // POST: /parser/import public ActionResult Import() { try { var parsed = TempData["ExchangeItems"] as List<ParsedItem>; if (parsed == null) { throw new ArgumentNullException("Information about sizes", "No parsed items. Bad data?!"); } var db = new EfProductRepository(); foreach (var item in parsed) { var product = new OnBalance.Domain.Entities.Product(); //product.CategoryId = product.InternalCode = item.InternalCode; product.Name = item.ProductName; product.PosId = 500000; product.Price = item.PriceOfRelease; product.StatusId = (byte)Status.Pending; product.UserId = User.Identity.Name; product.Uid = Common.EncodeHex(Common.CalculateMd5(string.Format("{0}-{1}-{2}", User.Identity.Name, product.PosId, product.InternalCode))); product.CreatedAt = DateTime.UtcNow; db.Save(product); foreach (var size in item.Sizes) { var pd = new OnBalance.Domain.Entities.ProductDetail(); pd.ProductId = product.Id; pd.ParameterName = "size"; pd.ParameterValue = size.Size; pd.Quantity = size.Quantity; pd.StatusId = (byte)Status.Pending; pd.PriceMinor = (int)(item.Price * 100); pd.PriceReleaseMinor = (int)(item.PriceOfRelease * 100); pd.CreatedAt = DateTime.UtcNow; pd.UpdatedAt = DateTime.UtcNow; db.Save(pd); } //var bi = new OnBalance.Domain.Entities.BalanceItem(); //bi.InternalCode = item.InternalCode; //bi.PosId = 500001; //bi.Price = item.Price; //bi.PriceOfRelease = item.PriceOfRelease; //bi.ProductName = item.ProductName; //bi.Quantity = item.Quantity; //bi.StatusId = (byte)OnBalance.Status.Pending; //db.Save(bi); } db.SubmitChanges(); return View("Import", "_LayoutLogin"); } catch (Exception ex) { Error("Error importing parsed products", ex); return Content(ex.Message); } }
// // POST: /parser/import public ActionResult Import() { try { var parsed = TempData["ExchangeItems"] as List <ParsedItem>; if (parsed == null) { throw new ArgumentNullException("Information about sizes", "No parsed items. Bad data?!"); } var db = new EfProductRepository(); foreach (var item in parsed) { var product = new OnBalance.Domain.Entities.Product(); //product.CategoryId = product.InternalCode = item.InternalCode; product.Name = item.ProductName; product.PosId = 500000; product.Price = item.PriceOfRelease; product.StatusId = (byte)Status.Pending; product.UserId = User.Identity.Name; product.Uid = Common.EncodeHex(Common.CalculateMd5(string.Format("{0}-{1}-{2}", User.Identity.Name, product.PosId, product.InternalCode))); product.CreatedAt = DateTime.UtcNow; db.Save(product); foreach (var size in item.Sizes) { var pd = new OnBalance.Domain.Entities.ProductDetail(); pd.ProductId = product.Id; pd.ParameterName = "size"; pd.ParameterValue = size.Size; pd.Quantity = size.Quantity; pd.StatusId = (byte)Status.Pending; pd.PriceMinor = (int)(item.Price * 100); pd.PriceReleaseMinor = (int)(item.PriceOfRelease * 100); pd.CreatedAt = DateTime.UtcNow; pd.UpdatedAt = DateTime.UtcNow; db.Save(pd); } //var bi = new OnBalance.Domain.Entities.BalanceItem(); //bi.InternalCode = item.InternalCode; //bi.PosId = 500001; //bi.Price = item.Price; //bi.PriceOfRelease = item.PriceOfRelease; //bi.ProductName = item.ProductName; //bi.Quantity = item.Quantity; //bi.StatusId = (byte)OnBalance.Status.Pending; //db.Save(bi); } db.SubmitChanges(); return(View("Import", "_LayoutLogin")); } catch (Exception ex) { Error("Error importing parsed products", ex); return(Content(ex.Message)); } }
public ActionResult Edit(OnBalance.Domain.Entities.Product model) { if (ModelState.IsValid) { model = _productRepository.GetById(model.Id); UpdateModel <OnBalance.Domain.Entities.Product>(model); _productRepository.Update(model); _productRepository.SubmitChanges(); return(RedirectToAction("Edit", new { id = model.Id })); } return(View(model)); }
public ActionResult Create(OnBalance.Domain.Entities.Product model) { try { InfoFormat("User #{0} saving new product", User.Identity.Name); SetTempOkMessage("New product '{0}' was created", model.Name); return(RedirectToAction("edit", new { id = model.Id })); } catch (Exception ex) { Error("Error creating product!", ex); ModelState.AddModelError("", ex.Message); } return(View(model)); }
public ActionResult Create(int id) { InfoFormat("Creating product in POS with ID #{0}", id); var pos = _organizationRepository.GetById(id); if (pos == null) { return(RedirectToAction("notfound", "help")); } OnBalance.Domain.Entities.Product model = new OnBalance.Domain.Entities.Product(); model.PosId = pos.Id; model.CategoryId = int.Parse(Request["category"]); return(View(model)); }
public Product(OnBalance.Domain.Entities.Product product) { Id = product.Id; CategoryId = product.CategoryId; CreatedAt = product.CreatedAt; InternalCode = product.InternalCode; Name = product.Name; PosId = product.PosId; Price = product.Price; StatusId = product.StatusId; Uid = product.Uid; UserId = product.UserId; ProductDetails = product.ProductDetails.Select(x => new OnBalance.Models.ProductDetail { id = x.Id, parameter_value = x.ParameterValue, quantity = x.Quantity, price_minor = x.PriceMinor, price_release_minor = x.PriceReleaseMinor, product_id = x.ProductId, DataJson = x.DataJson, }).ToList(); }
// // GET: /pradmin/edit/1234 public ActionResult Edit(int id) { InfoFormat("Editing product with ID #{0}", id); OnBalance.Domain.Entities.Product model = _productRepository.GetById(id); if (model == null) { ErrorFormat("User #{0} trying to edit non-existing product with ID: {1}!", User.Identity.Name, id); return(new HttpNotFoundResult()); } return(View(new Product { Id = model.Id, Name = model.Name, CategoryId = model.CategoryId, CreatedAt = model.CreatedAt, InternalCode = model.InternalCode, PosId = model.PosId, Price = model.Price, StatusId = model.StatusId, UserId = model.UserId, Uid = model.Uid, })); }
public ActionResult Create(int id) { InfoFormat("Creating product in POS with ID #{0}", id); var pos = _organizationRepository.GetById(id); if( pos == null ) { return RedirectToAction("notfound", "help"); } OnBalance.Domain.Entities.Product model = new OnBalance.Domain.Entities.Product(); model.PosId = pos.Id; model.CategoryId = int.Parse(Request["category"]); return View(model); }