public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,CompanyId,Status")] CompanyPeople companyPeople) { if (id != companyPeople.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(companyPeople); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyPeopleExists(companyPeople.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_context.Company, "Id", "Id", companyPeople.CompanyId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", companyPeople.UserId); return(View(companyPeople)); }
public async Task <IActionResult> AcceptAdminRequest(int id) { if (ModelState.IsValid) { try { CompanyPeople companyPeople = new CompanyPeople() { Id = id, Status = 1 }; _context.Attach(companyPeople); _context.Entry(companyPeople).Property("Status").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyPeopleExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(CompanyAdminRequest))); } return(View()); }
public async Task <IActionResult> CompanySetAdmin(string userId, int companyId) { if (ModelState.IsValid) { CompanyPeople companyPeople = new CompanyPeople() { UserId = userId, CompanyId = companyId, Status = 4 }; _context.Add(companyPeople); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(CompanyAddAdmin)); return(RedirectToAction("CompanyAddAdmin", new { id = companyId, Messege = "Admin Request is Sent" })); } return(View()); }
public async Task <IActionResult> FollowaCompany(int companyId) { if (ModelState.IsValid) { CompanyPeople companyPeople = new CompanyPeople() { UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), CompanyId = companyId, Status = 2 }; _context.Add(companyPeople); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(CompanyAddAdmin)); return(RedirectToAction("CompanyAbout", "CompanyProfile", new { id = companyId })); } return(View()); }
public async Task <IActionResult> CreateCompany([Bind("Id,Name,Objective,CoverPic,About,Services,CaseStudy,Address,Phone,Email,Instalation")] Company company) { if (ModelState.IsValid) { company.CreateTime = DateTime.Now; _context.Add(company); await _context.SaveChangesAsync(); CompanyPeople companyPeople = new CompanyPeople() { CompanyId = company.Id, UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), Status = 0 }; _context.Add(companyPeople); await _context.SaveChangesAsync(); return(RedirectToAction("CompanyAbout", new { id = company.Id })); } return(View(company)); }