コード例 #1
0
        public Response <bool> UpdateHotel(int Mhid, Model.Add.Hotel item)
        {
            var response = _repository.UpdateHotel(Mhid, item);

            if (response)
            {
                return(new Response <bool>(true));
            }

            return(new Response <bool>(false, Infrastructure.Utils.Enums.ResponseCodes.BadRequest, "Failed to Update the data ."));
        }
コード例 #2
0
        public async Task <ActionResult> UpdateHotelDetails(int Mhid, Model.Add.Hotel item)
        {
            Log.Information("Hotel information update processor  Started");
            var response = _processor.UpdateHotel(Mhid, item);

            if (response.ResponseCode == Infrastructure.Utils.Enums.ResponseCodes.OK)
            {
                Log.Information("Hotel information updated successfully");
                return(Ok(response));
            }
            return(BadRequest(response.Messages));
        }
コード例 #3
0
        public async Task <Response <bool> > AddHotel(Model.Add.Hotel hotel)
        {
            var response = _repository.AddHotel(hotel);

            if (response > 0)
            {
                return(new Response <bool>(true));
            }
            if (response == -1)
            {
                return(new Response <bool>(false, Infrastructure.Utils.Enums.ResponseCodes.AlreadyExist, "Hotel Already Exists"));
            }
            return(new Response <bool>(false, Infrastructure.Utils.Enums.ResponseCodes.BadRequest, "Saving of Hotel information failed."));
        }
コード例 #4
0
        public async Task <ActionResult> AddHotel(Model.Add.Hotel item)
        {
            Log.Information("Adding hotel information process started");

            var response = await _processor.AddHotel(item);

            if (response.ResponseCode == Infrastructure.Utils.Enums.ResponseCodes.OK)
            {
                Log.Information("Hotel information Added sucessfully");
                return(Ok(response));
            }
            if (response.ResponseCode == Infrastructure.Utils.Enums.ResponseCodes.AlreadyExist)
            {
                Log.Warning("Hotel name Already exists");
                return(Ok(response));
            }
            return(BadRequest(response));
        }
コード例 #5
0
        //Update Hotel Information based on Mhid
        public bool UpdateHotel(int mhid, Model.Add.Hotel item)
        {
            using (var con = new SqlConnection(_dbContext.DataBaseConnectionString))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                DynamicParameters parameters = new DynamicParameters();

                parameters.Add("@name", item.Name);
                parameters.Add("@description", item.Description);
                parameters.Add("@hotelImage", item.HotelImage);
                parameters.Add("@price", item.Price);
                parameters.Add("@Mhid", mhid);
                return(con.Execute("UpdateHotelDetails_V1", parameters, commandType: CommandType.StoredProcedure) > 0);
            }
        }
コード例 #6
0
 //Add hotel information into thew database
 public int?AddHotel(Model.Add.Hotel item)
 {
     using (var connection = new SqlConnection(_dbContext.DataBaseConnectionString))
     {
         DynamicParameters parameters = new DynamicParameters();
         bool IsExist = HotelExistsByName(item.Name);
         if (IsExist)
         {
             Log.Warning("Hotel Alreday Exists");
             return(-1);
         }
         else
         {
             parameters.Add("@Name", item.Name.ToUpper());
             parameters.Add("@Description", item.Description);
             parameters.Add("@HotelImage", item.HotelImage);
             parameters.Add("@Price", item.Price);
             parameters.Add("@Mhid", null, DbType.Int32, ParameterDirection.Output);
             connection.Execute("InsertHotelDetails_V1", parameters, commandType: CommandType.StoredProcedure);
             int response = parameters.Get <int>("@Mhid");
             return(response > 0 ? response : (int?)null);
         }
     }
 }