public async Task <IActionResult> Edit(int id) { CompanyDetailsServiceModel company = await this._companyServices.GetByIdAsync(id); if (company == null) { return(NotFound()); } List <OfficeDetailsViewModel> offices = company.Offices .Select(x => new OfficeDetailsViewModel { City = x.City, OfficeId = x.OfficeId, Country = x.Country, IsHQ = x.IsHQ == true ? "The office is Headquarter" : "", Street = x.Street, StreetNumber = x.StreetNumber }) .ToList(); CompanyEditBindingModel model = new CompanyEditBindingModel() { CompanyId = company.CompanyId, Name = company.Name, CreationDate = company.CreationDate, EmployeesOffices = offices, }; return(View(model)); }
public async Task <IActionResult> Dashboard(CompanyEditBindingModel model) { var jobCategories = await this.GetAllJobCategoriesAsync(); model.JobCategories = jobCategories; var company = await companyService.GetCompanyForUser(User.Identity.Name); model.JobsCount = company.Jobs.Count; model.SubmittedApplications = company.Jobs.Sum(x => x.JobCandidates.Count); if (!ModelState.IsValid) { return(View(model)); } var updatedCompany = Mapper.Map <CompanyServiceModel>(model); updatedCompany.Id = company.Id; var result = await this.companyService.UpdateAsync(updatedCompany); if (result == false || company == null) { return(NotFound()); } this.Success(NotificationMessages.SuccessfullUpdateForCompany); return(View(model)); }
public async Task <IActionResult> Edit(CompanyEditBindingModel model) { if (!ModelState.IsValid) { return(View()); } var company = await this.companyService.EditCompanyAsync(model); return(this.RedirectToAction("Details", new { id = company.CompanyId })); }
public async Task <IActionResult> Edit(CompanyEditBindingModel model) { if (ModelState.IsValid) { CompanyEditServiceModel serviceModel = new CompanyEditServiceModel() { CompanyId = model.CompanyId, CreationDate = model.CreationDate, Name = model.Name }; bool result = await this._companyServices.UpdateAsync(serviceModel); if (!result) { return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Details", new { id = model.CompanyId })); } return(View(model)); }
public async Task <Company> EditCompanyAsync(CompanyEditBindingModel model) { var dbCompany = await GetCompanyById(model.CompanyId); var town = await this.townsService.GetTownByName(model.TownName); if (town == null) { var townToAdd = new TownCreationBindingModel { Name = model.TownName }; town = await this.townsService.AddTownAsync(townToAdd); } dbCompany.TownId = town.TownId; dbCompany.Address = model.Address; dbCompany.Bulstat = model.Bulstat; dbCompany.Name = model.Name; await this.DbContext.SaveChangesAsync(); return(dbCompany); }