Пример #1
0
        public async Task <BaseApiResponse> CreateHouse(CreateHouse model)
        {
            var validation = Validate(model);

            if (!validation.IsSucceeded)
            {
                return(validation);
            }

            var set = Context.Set <House>();

            if (await set.AnyAsync(x => x.Address == model.Address))
            {
                return(new BaseApiResponse(false, MainResources.HouseWithTheSameAdressAlreadyExists));
            }

            set.Add(new House
            {
                Address = model.Address
            });

            return(await TrySaveChangesAndReturnResultAsync(MainResources.HouseCreated));
        }
Пример #2
0
 public Task <BaseApiResponse> CreateHouse(CreateHouse model)
 {
     return(HouseService.CreateHouse(model));
 }