public async Task <int> DevHub_AmenityRates_Set(AmenityRatesForCreateModel model, string userName)
        {
            using (var con = GetDbConnection(_options.Value.DevHubDBConn))
            {
                var result = await con.QueryAsync <int>("dbo.DevHub_AmenityRates_Set",
                                                        new
                {
                    @iIntRateID      = model.RateId,
                    @iIntAmenityID   = model.AmenityId,
                    @iIntFrequencyID = model.FrequencyId,
                    @iDecRateValue   = model.RateValue,
                    @iStrCapacity    = model.Capacity,
                    @iStrUserName    = userName
                },
                                                        commandType : CommandType.StoredProcedure);

                return(result.FirstOrDefault());
            }
        }
Пример #2
0
        public async Task <IActionResult> AmenityRatesInsert([FromBody] AmenityRatesForCreateModel model)
        {
            if (await _service.AmenityRateExists(model.AmenityId, model.FrequencyId, model.Capacity))
            {
                ModelState.AddModelError("AmenityRate", "Rate is already defined.");
            }

            // validate request
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var amenityRateToCreate = await _service.DevHub_AmenityRates_Set(model, _baseUserName);

            if (amenityRateToCreate == 0)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
Пример #3
0
        public async Task <IActionResult> AmenityRatesUpdate([FromBody] AmenityRatesForCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var chkRate = await _service.DevHub_AmenityRates_Get(model.AmenityId, model.RateId);

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

            var amenityRateToUpdate = await _service.DevHub_AmenityRates_Set(model, _baseUserName);

            if (amenityRateToUpdate == 0)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
Пример #4
0
 public async Task <int> DevHub_AmenityRates_Set(AmenityRatesForCreateModel model, string userName)
 {
     return(await _repo.DevHub_AmenityRates_Set(model, userName));
 }