示例#1
0
        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);
        }
示例#2
0
        public IActionResult CreateOffice(OfficeCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _officeRepository.CreateOffice(request);
            return(Ok());
        }
示例#3
0
        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"));
        }
示例#4
0
 public IActionResult CreateOffice([FromBody] Office office)
 {
     _officeRepo.CreateOffice(office);
     return(Ok("Office Created"));
 }