public async Task <IActionResult> CreateAdministrator(AdministratorRequest request) { var result = await _administratorService.CreateAdministrator(request); if (result.Errors != null) { return(BadRequest(result.Errors)); } return(Ok(result.Data)); }
public IActionResult CreateAdministrator([FromBody] AdministratorModel administrator) { try { Company company = companyService.GetCompanyByName(administrator.CompanyName); Administrator admin = administrator.ToEntity(); admin.Company = company; administratorService.CreateAdministrator(admin); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public IHttpActionResult PostAdministrator(AdministratorCreateDTO newAdministrator) { Administrator administrator = new Administrator(); administrator.FirstName = newAdministrator.FirstName; administrator.LastName = newAdministrator.LastName; administrator.Username = newAdministrator.Username; administrator.Password = newAdministrator.Password; administrator.Country = newAdministrator.Country; administrator.City = newAdministrator.City; if (newAdministrator.RepeatedPassword != newAdministrator.Password) { return(BadRequest("RepeatedPassword must be the same as Password")); } Administrator createdAdministrator = administratorService.CreateAdministrator(administrator); return(Created("", createdAdministrator)); }