public async Task <object> CreateBusinessCenter(BaseBuildingDto buildingDto) { try { Building building = new Building { Name = buildingDto.Name, Height = buildingDto.Height, Floors = buildingDto.Floors, Address = buildingDto.Address, Price = buildingDto.Price, BuilderId = buildingDto.BuilderId }; await _uow.Repository <Building>().CreateAsync(building); await _uow.CommitAsync(); return(buildingDto); } catch (Exception exception) { throw new Exception(exception.Message); } throw new NotImplementedException(); }
public async Task <BaseResponse <bool> > Put(int id, [FromBody] BaseBuildingDto buildingDto) { try { return(new BaseResponse <bool>(await _businessCenterService.UpdateBusinessCenter(id, buildingDto))); } catch (Exception exception) { return(new BaseResponse <bool>(exception)); } }
public async Task <BaseResponse <BaseBuildingDto> > Post([FromBody] BaseBuildingDto data) { try { return(new BaseResponse <BaseBuildingDto>((BaseBuildingDto)await _businessCenterService.CreateBusinessCenter(data))); } catch (Exception exception) { return(new BaseResponse <BaseBuildingDto>(exception)); } }
public async Task <bool> UpdateBusinessCenter(int id, BaseBuildingDto buildingDto) { Building building = await _uow.Repository <Building>().GetAsync(id); building.Name = buildingDto.Name; building.Address = buildingDto.Address; building.Height = buildingDto.Height; building.Floors = buildingDto.Floors; building.BuilderId = buildingDto.BuilderId; building.Price = buildingDto.Price; _uow.Repository <Building>().Update(building); await _uow.CommitAsync(); return(true); }