public async Task <IActionResult> Add(InputCompanyViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var companyId = await this._companiesService.Add(model); this.TempData[GlobalConstants.SuccessMessageKey] = "Company" + GlobalConstants.SuccessfullyAddedMessage; return(this.Redirect("Add")); }
public async Task <int> Add(InputCompanyViewModel model) { var country = this._countriesService.GetById(model.CountryId); var company = new Company { Name = model.Name, Address = model.Address, PhoneNumber = model.PhoneNumber, Country = country, Email = model.Email }; await this._companiesRepository.AddAsync(company); await this._companiesRepository.SaveChangesAsync(); return(company.Id); }