public async Task <IActionResult> Create(ProductViewModel pvm) { if (!ModelState.IsValid) { return(ViewWithSupplierList()); } ; ProductDBModel product = null; try { product = await pvm.ToProductDB(); } catch (FileUploadFailedException e) { Expression <Func <ProductViewModel, IFormFileCollection> > expression = p => p.ImageFiles; string key = ExpressionHelper.GetExpressionText(expression); ModelState.AddModelError(key, e.Message); } if (ModelState.IsValid) { product.SupplierID = Utils.IsInternalUser(User) ? product.SupplierID : Utils.SupplierID(User); _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(ViewWithSupplierList()); }
private void Zapamti_Click(object sender, RoutedEventArgs e) { using (var db = new InventoryContext()) { try { uzmiPodatkeRadnikaIzPolja(); if (dodavanjeNovogPredmeta) { db.Add(predmet); db.SaveChanges(); } else { Predmet p = db.Predmeti.Find(predmet.Id); p.Id = predmet.Id; p.Naziv = predmet.Naziv; p.Marka = predmet.Marka; p.Model = predmet.Model; p.Cena = predmet.Cena; db.SaveChanges(); } NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Greska"); } } }
public async Task <IActionResult> Create([Bind("WhardId,WhardInumber,WhardFnumber,WhardWcatId,WhardWtypeId,WhardName" + ",WhardDateOfAdoption,WhardInitialCost,WhardResidualValue,WhardOfficeId" + ",WhardNote,WhardArchiv,WhardCreateDate,WhardMolEmployeeId,WhardRegionId,IsSoftDeployed")] WealthHardware wealthHardware, bool WhardArchiv, bool IsSoftDeployed, string filter = "", int page = 1, string sortExpression = "WhardId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; wealthHardware.WhardArchiv = WhardArchiv ? 1 : 0; wealthHardware.IsSoftDeployed = IsSoftDeployed ? 1 : 0; ModelState.Clear(); if (ModelState.IsValid) { _context.Add(wealthHardware); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["WhardMolEmployeeId"] = _ControlesItems.GetMOLEmployeesByRegion(wealthHardware.WhardRegion.RegionId); ViewData["WhardOfficeId"] = _ControlesItems.GetOfficesByRegion(wealthHardware.WhardRegion.RegionId); ViewData["WhardRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName", wealthHardware.WhardRegionId); ViewData["WhardWcatId"] = new SelectList(_context.WealthCategories, "WcatId", "Wcatname", wealthHardware.WhardWcatId); ViewData["WhardWtypeId"] = new SelectList(_context.WealthTypes, "WtypeId", "WtypeName", wealthHardware.WhardWtypeId); return(View(wealthHardware)); }
public async Task <IActionResult> Create([Bind("RoeId,RoeOfficeId,RoeEmployeeId")] RelOfficeResponsEmployee relOfficeResponsEmployee, string filter = "", int page = 1, string sortExpression = "RoeId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; if (ModelState.IsValid) { _context.Add(relOfficeResponsEmployee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { page = page, filter = filter, sortExpression = sortExpression })); } ViewData["OfficeRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName" , relOfficeResponsEmployee.RoeOffice.OfficeHouses.HousesRegionId); ViewData["OfficeHousesId"] = new SelectList(_context.Houses, "HouseId", "HouseName" , relOfficeResponsEmployee.RoeOffice.OfficeHousesId); ViewData["RoeEmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeFullFio" , relOfficeResponsEmployee.RoeEmployeeId); ViewData["RoeOfficeId"] = new SelectList(_context.Offices, "OfficeId", "OfficeName" , relOfficeResponsEmployee.RoeOfficeId); return(View(relOfficeResponsEmployee)); }
public async Task <IActionResult> Create([Bind("OfficeId,OfficeName,OfficeNotes,OfficeHousesId,OfficeIsStore")] Offices offices, bool OfficeIsStore, string filter = "", int page = 1, string sortExpression = "OfficeId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; offices.OfficeIsStore = OfficeIsStore ? 1 : 0; ModelState.Clear(); if (ModelState.IsValid) { _context.Add(offices); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["OfficeRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName"); ViewData["OfficeHousesId"] = new SelectList(_context.Houses, "HouseId", "HouseName"); return(View(offices)); }
private void Zapamti_Click(object sender, RoutedEventArgs e) { using (var db = new InventoryContext()) { try { uzmiPodatkeRadnikaIzPolja(); if (dodavanjeNovogRadnika) { db.Add(radnik); db.SaveChanges(); } else { Radnik r = db.Radnici.First(r => r.Username == radnik.Username); r.Ime = radnik.Ime; r.Prezime = radnik.Prezime; r.JMBG = radnik.JMBG; r.Pol = radnik.Pol; r.StrucnaSprema = radnik.StrucnaSprema; r.IsAdmin = radnik.IsAdmin; db.SaveChanges(); } NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Greska"); } } }
public async Task <IActionResult> Create([Bind("WsoftId,WsoftInumber,WsoftFnumber,WsoftWcatId,WsoftWtypeId,WsoftName" + ",WsoftDateOfAdoption,WsoftInitialCost,WsoftResidualValue,WsoftRegionId" + ",WsoftNote,WsoftArchiv,WsoftCreateDate,WsoftCnt")] WealthSoftware wealthSoftware, bool WsoftArchiv, string filter = "", int page = 1, string sortExpression = "WsoftId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; wealthSoftware.WsoftArchiv = WsoftArchiv ? 1 : 0; ModelState.Clear(); if (ModelState.IsValid) { _context.Add(wealthSoftware); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["WsoftRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName", wealthSoftware.WsoftRegionId); ViewData["WsoftWcatId"] = new SelectList(_context.WealthCategories, "WcatId", "Wcatname", wealthSoftware.WsoftWcatId); ViewData["WsoftWtypeId"] = new SelectList(_context.WealthTypes, "WtypeId", "WtypeName", wealthSoftware.WsoftWtypeId) .Where(t => t.Value == "105" || t.Value == "102"); return(View(wealthSoftware)); }
public async Task <IActionResult> Create([Bind( "EmployeeId," + "EmployeeFirstname,EmployeeLastname,EmployeeMiddlename," + "EmployeeEmail,EmployeePositionId,EmployeeOfficeId,EmployeePhoneWork," + "EmployeeNote,EmployeeFullFio,EmployeeIsRespons,EmployeeIsMol,EmployeeRegionId")] Employees employees, bool EmployeeIsRespons = false, bool EmployeeIsMol = false, string filter = "", int page = 1, string sortExpression = "EmployeeId") { employees.EmployeeIsRespons = EmployeeIsRespons ? 1 : 0; employees.EmployeeIsMol = EmployeeIsMol ? 1 : 0; employees.EmployeeFullFio = $"{employees.EmployeeLastname} {employees.EmployeeFirstname} {employees.EmployeeMiddlename}"; ModelState.Clear(); if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["EmployeeOfficeId"] = new SelectList(_context.Offices, "OfficeId", "OfficeName", employees.EmployeeOfficeId); ViewData["EmployeePositionId"] = new SelectList(_context.Positions, "PositionId", "PositionName", employees.EmployeePositionId); ViewData["EmployeeRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName", employees.EmployeeRegionId); return(View(employees)); }
public async Task <IActionResult> Create([Bind("PositionId,PositionName,PositionNotes,PositionDepartmentId")] Positions positions, string filter = "", int page = 1, string sortExpression = "PositionId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; if (ModelState.IsValid) { _context.Add(positions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["PositionDepartmentId"] = new SelectList(_context.Departments, "DepartmentId", "DepartmentId", positions.PositionDepartmentId); ViewData["PositionRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName"); return(View(positions)); }
private void Zapamti_Click(object sender, RoutedEventArgs e) { using (var db = new InventoryContext()) { try { uzmiPodatkeProstorijeIzPolja(); // Recimo da ovo ovako mora, zbog nekih cuda sa ef core prostorija.SefProstorije = db.Radnici.Find(cbUsernameSefa.Text); if (dodavanjeNoveProstorije) { db.Add(prostorija); db.SaveChanges(); } else { Prostorija p = db.Prostorije.First(p => p.Id == prostorija.Id); p.NazivProstorije = prostorija.NazivProstorije; p.Sprat = prostorija.Sprat; p.Sirina = prostorija.Sirina; p.Duzina = prostorija.Duzina; p.Visina = prostorija.Visina; p.SefProstorije = prostorija.SefProstorije; db.SaveChanges(); } NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Greska"); } } }
public async Task <IActionResult> Create([Bind("Idproduct,Product1,IdCategory")] Product product, int Idemployee = 0) { if (HttpContext.Session.GetString("employeeID") != null) { Idemployee = int.Parse(HttpContext.Session.GetString("employeeID")); var employee = _context.Employee.FirstOrDefault(a => a.Idemployee == Idemployee); if (employee.Role == "USER") { TempData["message"] = "You are not authorized to Add Products"; return(Redirect("/Home")); } } if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdCategory"] = new SelectList(_context.Category, "Idcategory", "Namecategory", product.IdCategory); return(View(product)); }
private void Zapamti_Click(object sender, RoutedEventArgs e) { using (var db = new InventoryContext()) { try { var predmet = cbPredmet.SelectedItem as Predmet; var kolicina = int.Parse(tbKolicina.Text); var i = new Inventory.Inventar { Predmet = db.Predmeti.Find(predmet.Id), Kolicina = kolicina, Prostorija = db.Prostorije.Find(prostorija.Id) }; db.Add(i); db.SaveChanges(); NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show("Greska prilikom dodavanja novog predmeta u inventar"); } } }
public void CreateProduct(ProductEntity oProduct) { using (var db = new InventoryContext()) { db.Add(oProduct); db.SaveChanges(); } }
public void CreateWareHouse(WarehouseEntity oWareHouse) { using (var db = new InventoryContext()) { db.Add(oWareHouse); db.SaveChanges(); } }
public void CreateInOut(InputOutputEntity oInOut) { using (var db = new InventoryContext()) { db.Add(oInOut); db.SaveChanges(); } }
public async Task Handle(InventoryItemCreated message) { _context.Add(new InventoryItemDetails() { Id = message.AggregateId, Name = message.Name, Version = message.Version, }); _context.Add(new InventoryItemList() { Id = message.AggregateId, Name = message.Name }); _context.SaveChanges(); }
public void CreateStorage(StorageEntity oStorage) { using (var db = new InventoryContext()) { db.Add(oStorage); db.SaveChanges(); } }
public async Task <IActionResult> New(int id, [Bind("id,itemName,alertType,lowStockThreshold")] StockAlert stockAlert) { if (id != stockAlert.id) { return(NotFound()); } if (ModelState.IsValid) { try { // Create new alert User user = HttpContext.Items["user"] as User; var qStock = from s in _context.Stock where s.itemName == stockAlert.itemName && s.userId == user.id select s; Stock stock = await qStock.SingleAsync(); stockAlert.stock = stock; stockAlert.active = true; stockAlert.user = user; stockAlert.userId = user.id; //Trigger alert if necessary if (stockAlert.alertType == StockAlert.AlertType.outOfStock && stock.count == 0) { stockAlert.triggered = true; } else if (stockAlert.alertType == StockAlert.AlertType.lowStock && stock.count < stockAlert.lowStockThreshold) { stockAlert.triggered = true; } else { stockAlert.triggered = false; } _context.Add(stockAlert); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockAlertExists(stockAlert.id)) { return(NotFound()); } else { throw; } } } return(RedirectToAction(nameof(Index))); }
private void Zaduzi_Click(object sender, RoutedEventArgs e) { var zaZaduzivanje = InventarDataGrid.Items.Cast <Inventory.Inventar>().ToList(); if (zaZaduzivanje.Count == 0) { MessageBox.Show("Lista mora da sadrzi minimum jedan element!"); return; } var radnikKojiPrimaInventar = cbRadnici.SelectedItem as Radnik; if (radnikKojiPrimaInventar == null) { MessageBox.Show("Morate za odaberete radnika koji zaduzuje inventar!"); return; } using (var db = new InventoryContext()) { foreach (var predmet in zaZaduzivanje) { var inventar = db.Inventar.Include(i => i.Predmet); var predmetUBazi = inventar.First(i => i.Predmet.Id == predmet.Predmet.Id); if (predmetUBazi.Kolicina < predmet.Kolicina) { MessageBox.Show("Ne mozete da razduzite vise predmeta nego sto se nalazi u inventaru!"); return; } else if (predmetUBazi.Kolicina == predmet.Kolicina) { // ako hoce sve da uzme onda ga izbrisi iz baze db.Remove(predmetUBazi); } else { predmetUBazi.Kolicina -= predmet.Kolicina; } // Unesi u tabelu Zaduzenje db.Add(new Zaduzenje { RadnikKojiDajeInventar = db.Radnici.Find((Application.Current as App).trenutniRadnik.Username), RadnikKojiPrimaInventar = db.Radnici.Find(radnikKojiPrimaInventar.Username), Predmet = db.Predmeti.Find(predmet.Predmet.Id), Prostorija = db.Prostorije.Find(predmet.Prostorija.Id), Kolicina = predmet.Kolicina, DatumZaduzivanja = DateTime.Now }); } db.SaveChanges(); } // Predji na page gde se stampa izvestaj NavigationService.Navigate(new ZavrsiZaduzivanje(zaZaduzivanje, radnikKojiPrimaInventar)); }
public async Task <IActionResult> Create([Bind("Productcode,Name,Price")] Products products) { if (ModelState.IsValid) { _context.Add(products); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(Json(products)); }
public async Task <IActionResult> Create([Bind("Idcity,Namecity,Province")] City city) { if (ModelState.IsValid) { _context.Add(city); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(city)); }
public async Task <IActionResult> Create([Bind("ProductId,Name,Category,Color,UnitPrice,AvailableQuantity,CratedDate")] Products products) { if (ModelState.IsValid) { _context.Add(products); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(products)); }
public async Task <IActionResult> Create([Bind("UserId,FirstName,LastName,UserName,Email,Password,CreatedDate")] UserInfo userInfo) { if (ModelState.IsValid) { _context.Add(userInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userInfo)); }
public async Task <IActionResult> Create([Bind("Idemployee,Name,Email,Gender,Role")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("RegionId,RegionName")] Region region) { if (ModelState.IsValid) { _context.Add(region); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(region)); }
public async Task <IActionResult> Create([Bind("Id,Username,Name,Email,CreatedOn")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Company supplier) { if (ModelState.IsValid) { _context.Add(supplier); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(supplier)); }
//[ValpidateAntiForgeryToken] public async Task <IActionResult> Create([Bind("pid,username,phone,price")] Products products) { if (ModelState.IsValid) { _context.Add(products); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(products)); }
public async Task <IActionResult> Create([Bind("Id,Name,DecimalSize,MetricSize")] Caliber caliber) { if (ModelState.IsValid) { _context.Add(caliber); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(caliber)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,City,State,Website")] Manufacturer manufacturer) { if (ModelState.IsValid) { _context.Add(manufacturer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(manufacturer)); }