public async Task <ApiResponse> GetOfficeById(long id)
        {
            var office = await _officeRepo.FindOfficeById(id);

            if (office == null)
            {
                return(new ApiResponse(404));
            }
            var officeTransferDTOs = _mapper.Map <OfficeTransferDTO>(office);

            return(new ApiOkResponse(officeTransferDTOs));
        }
示例#2
0
        public IActionResult DeleteOffice(int id)
        {
            var office = _officeRepository.FindOfficeById(id);

            if (office == null)
            {
                return(NotFound());
            }

            _officeRepository.DeleteOffice(office);
            return(Ok());
        }
示例#3
0
        public ResponseViewModel UpdateOffice(OfficeViewModel model)
        {
            var office = _officeRepository.FindOfficeById(model.Id);

            if (office != null)
            {
                office.Name   = model.Name;
                office.Adress = model.Adress;
                _officeRepository.UpdateOffice(office);
                return(new ResponseViewModel()
                {
                    Message = "Update!",
                    Result = true
                });
            }
            else
            {
                return(new ResponseViewModel()
                {
                    Message = "Not Update!",
                    Result = false
                });
            }
        }