public ReturnOfficeDetailDto CreateOffice(CreateOfficeDto createOfficeDto) { var office = officeRepository.CreateOffice(new Office(createOfficeDto.Name, createOfficeDto.Location, createOfficeDto.OpenHour, createOfficeDto.CloseHour)); var returnOffice = new ReturnOfficeDetailDto(office.Id, office.Name, office.Location, office.OpenHour, office.CloseHour, office.Rooms, office.Employees); return(returnOffice); }
public IActionResult CreateOffice(OfficeCreateRequest request) { if (!ModelState.IsValid) { return(BadRequest()); } _officeRepository.CreateOffice(request); return(Ok()); }
public IActionResult CreateOffice(Office office) { if (!ModelState.IsValid) { return(BadRequest("Modal state is not valid")); } var exists = _officeRepo.GetOffices().FirstOrDefault(o => o.Name == office.Name); if (exists != null) { return(BadRequest("Office name already exists.")); } _officeRepo.CreateOffice(office); return(RedirectToRoute("Offices")); }
public IActionResult CreateOffice([FromBody] Office office) { _officeRepo.CreateOffice(office); return(Ok("Office Created")); }