public IActionResult Company(BOCompanyViewModel model) { if (!User.Identity.IsAuthenticated) { TempData["Got-Error"] = "true"; TempData["Login-Message"] = "É necessário iniciar sessão"; return(RedirectToAction("Index", "Home")); } Company company = new Company { IdCompany = model.Company.IdCompany, Name = model.Company.Name, Description = model.Company.Description, IdDistrict = model.Company.IdDistrict, Email = model.Company.Email }; _context.Company.Add(company); _context.SaveChanges(); TempData["HasAlert"] = "true"; TempData["AlertMessage"] = "Company added successfully."; return(RedirectToAction("Companies", "BackOffice")); }
/// <summary> /// Gets the Companies list view. /// </summary> /// <returns>Companies list view</returns> /// <remarks></remarks> public IActionResult Companies() { if (!User.Identity.IsAuthenticated) { TempData["Got-Error"] = "true"; TempData["Login-Message"] = "É necessário iniciar sessão"; return(RedirectToAction("Index", "Home")); } BOCompanyViewModel viewModel = new BOCompanyViewModel(); var companies = _context.Company; viewModel.Companies = companies; viewModel.Districts = PopulateDistricts(); return(View(viewModel)); }
public IActionResult EditCompany(BOCompanyViewModel model) { if (!User.Identity.IsAuthenticated) { TempData["Got-Error"] = "true"; TempData["Login-Message"] = "É necessário iniciar sessão"; return(RedirectToAction("Index", "Home")); } _context.Company.Update(model.Company); _context.SaveChanges(); TempData["HasAlert"] = "true"; TempData["AlertMessage"] = "Company edited successfully."; return(RedirectToAction("Companies", "BackOffice")); }