public void AddUser(User item) { int len = dbcontext.Users.Count(); item.UserID = (len + 1).ToString(); item.Confirmed = "User"; dbcontext.Users.Add(item); dbcontext.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Name,Code")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "Id,Description,StockDate")] StockIn stockIn) { if (ModelState.IsValid) { db.StockIns.Add(stockIn); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stockIn)); }
public ActionResult Create([Bind(Include = "Id,ProductId,Qty")] Inventory inventory) { if (ModelState.IsValid) { db.Inventories.Add(inventory); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", inventory.ProductId); return(View(inventory)); }
public ActionResult Create([Bind(Include = "Id,Name,Code")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); TempData["msg"] = "Category information has been successfully saved"; return(RedirectToAction("Index")); } TempData["msg"] = "Category information has been failed to save"; return(View(category)); }
public ActionResult Create([Bind(Include = "Id,Name,Code,CategoryId")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", product.CategoryId); return(View(product)); }
public ActionResult Create([Bind(Include = "Id,StockInId,ProductId,Qty")] StockInDetail stockInDetail) { if (ModelState.IsValid) { db.StockInDetails.Add(stockInDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", stockInDetail.ProductId); ViewBag.StockInId = new SelectList(db.StockIns, "Id", "Description", stockInDetail.StockInId); return(View(stockInDetail)); }
public void TestContext() { var config = new ConfigurationBuilder().Build(); string connection = config.GetConnectionString("StockDBConnection"); if (String.IsNullOrEmpty(connection)) { connection = "server=localhost;port=3306;database=stock;uid=jeesite;pwd=123456;charset=utf8;TreatTinyAsBoolean=true"; } StockDBContext sdb = new StockDBContext(connection); StockInfo si = sdb.StockInfos.Find("abc"); if (si == null) { si = new StockInfo() { Id = "abc", Name = "abc", BriefName = "abc", Type = StockType.Stock, Symbol = "abc", Market = "test", Status = StockStatus.Closed, }; sdb.StockInfos.Add(si); sdb.SaveChanges(); } si = sdb.StockInfos.Find("abc"); Assert.NotNull(si); Assert.Equal("abc", si.Id); var stockInfo = sdb.StockInfos.Where(t => t.Id == si.Id).FirstOrDefault(); Assert.NotNull(stockInfo); string key = "cn_070013_20190812"; var perf = sdb.StockPerfs.Find(key); if (perf == null) { perf = new StockPerf() { Id = key, Date = new DateTime(2019, 8, 12), StockId = "cn_070013", }; sdb.StockPerfs.Add(perf); } perf.Close = 1.78m; sdb.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Name,Code,CategoryId")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); TempData["msg"] = "Product information has been successfully saved."; return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", product.CategoryId); TempData["msg"] = "Product information has been failed to save"; return(View(product)); }
public ActionResult StockIn(StockCreateVM model) { //var stck = new StockIn() //{ // StocInDate = model.StocInDate, // Description = model.Description, // StockInDetails = model.StockInDetails //}; StockIn stockIn = Mapper.Map <StockIn>(model); db.StockIns.Add(stockIn); int isSaved = db.SaveChanges(); if (isSaved > 0) { TempData["msg"] = "Successful"; } model.Categories = db.Categories.ToList(); model.Parties = _partyManager.GetAll().ToList(); ViewBag.ProductDropDown = new SelectListItem[] { new SelectListItem() { Value = "", Text = "Select...." } }; return(View(model)); }
public ActionResult Create([Bind(Include = "Id,Name,Code")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); bool isSaved = db.SaveChanges() > 0; if (isSaved) { TempData["msg"] = "Catagory Inserted Successfully"; } return(RedirectToAction("Create")); } return(View(category)); }
public ActionResult StockIn(StockInViewModel stockInViewModel) { if (ModelState.IsValid) { StockIn stockIn = Mapper.Map <StockIn>(stockInViewModel); db.StockIns.Add(stockIn); if (db.SaveChanges() > 0) { ModelState.Clear(); TempData["msg"] = "StockIn information has been successfully saved."; return(RedirectToAction("Index", "StockInDetails", new { area = "" })); } } var model = new StockInViewModel(); model.Categories = db.Categories.ToList(); model.Parties = _partyManager.PartyList(); ViewBag.ProductDropDown = new SelectList(new[] { new SelectListItem() { Value = "", Text = "Select Product" } }, "Value", "Text"); TempData["msg"] = "StockIn information has been failed to save!"; return(View(model)); }
/// <summary> /// Crea una nueva producto /// </summary> /// <param name="product">Información del producto</param> /// <returns>Respuesta que información si se realizo la creación correctamente</returns> public ResponseService CreateProduct(Product product) { ResponseService response = new ResponseService(); if (ProductExists(product.ItemNo)) { response = response.GetIncorrectResponse(10, "The Product Exists"); } else { _context.Products.Add(product); _context.SaveChanges(); var productBD = _context.Products.Find(product.ItemNo); response = response.GetCorrectResponse(productBD, "The Product created correctly"); } return(response); }
public IList <StockPrice> ImportStock(string filepath) { FileInfo file = new FileInfo(filepath); string filename = file.Name; using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"]; int TotalRows = worksheet.Dimension.Rows; StockPrice stockPrice = new StockPrice(); int len = _db.StockPrices.ToList().Count(); for (int i = 2; i <= TotalRows; i++) { stockPrice = new StockPrice { DataID = (i - 1).ToString() + worksheet.Cells[i, 1].Value.ToString().Trim(), CompanyCode = worksheet.Cells[i, 1].Value.ToString().Trim(), CompanyName = worksheet.Cells[i, 2].Value.ToString().Trim(), PricePerShare = worksheet.Cells[i, 3].Value.ToString().Trim(), Date = DateTime.Parse(worksheet.Cells[i, 4].Value.ToString().Trim()), Time = worksheet.Cells[i, 5].Value.ToString().Trim() }; if (_db.StockPrices.Contains(stockPrice)) { continue; } _db.StockPrices.Add(stockPrice); } _db.SaveChanges(); return(_db.StockPrices.ToList()); } }
public ActionResult StockIn(StockInCreateVM model) { //insert logic against stockcreate StockIn stockIn = Mapper.Map <StockIn>(model); db.StockIns.Add(stockIn); if (db.SaveChanges() > 0) { ViewBag.Message = "Successful!"; } model.Categories = db.Categories.ToList(); model.Parties = _partyManager.GetAll().ToList(); ViewBag.ProductDropDown = new SelectListItem[] { new SelectListItem() { Value = "", Text = "Select..." } }; return(View(model)); }
public void ProcessDataAsync(string market, string symbol) { log.Info($"start retrieve stock info(market={market},symbol={symbol}"); string stockInfo = api.GetStockInfo(market + symbol); if (String.IsNullOrEmpty(stockInfo)) { log.Warn($"Can not retrieve any data for stock(market={market},symbol={symbol}"); return; } log.InfoFormat($"retrieved data({stockInfo}) for stock(market={market},symbol={symbol}"); string key = $"{market}{symbol}"; string[] values = stockInfo.Split(new char[] { ',' }); if (values.Length < 5) { return; } StockInfo si = stockDb.StockInfos.Find(key); if (si == null) { si = new StockInfo(); si.Id = key; si.CreatedOn = DateTime.Now; si.Status = StockStatus.Active; stockDb.Add(si); } si.Name = values[0]; si.Symbol = symbol; si.Market = market; si.Price = decimal.Parse(values[3]); si.Date = DateTime.Parse(values[30]); si.ModifiedOn = DateTime.Now; stockDb.SaveChanges(); log.Info($"successfully retrieved stock info(market={market},symbol={symbol}"); }
public void AddUser(User item) { context.Add(item); context.SaveChanges(); }
public void addCompany(Company company) { _context.Companies.Add(company); _context.SaveChanges(); }
public virtual bool Add(T entity) { db.Set <T>().Add(entity); return(db.SaveChanges() > 0); }
public bool Add(Party party) { db.Parties.Add(party); return(db.SaveChanges() > 0); }
public void AddCompany(Company company) { dbcontext.Companies.Add(company); dbcontext.SaveChanges(); }
public void addUser(User user) { _context.Users.Add(user); _context.SaveChanges(); }