Example #1
0
        public async Task <object> CreateBuilder(BaseBuilderDto builderDto)
        {
            try
            {
                if (string.IsNullOrEmpty(builderDto.Name) || string.IsNullOrEmpty(builderDto.Address) || string.IsNullOrEmpty(builderDto.BIN))
                {
                    throw new Exception("Properties should have value");
                }

                Builder builder = new Builder
                {
                    Name = builderDto.Name,
                    BIN  = builderDto.BIN,
                    ActivityStartDate = DateTime.Parse(builderDto.ActivityStartDate),
                    Address           = builderDto.Address,
                    IsDeleted         = false
                };

                await _uow.Repository <Builder>().CreateAsync(builder);

                await _uow.CommitAsync();

                return(builderDto);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        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();
        }