示例#1
0
        public int Adddata(object a)
        {
            RoomsDTO c = a as RoomsDTO;
            RoomsDTO b = new RoomsDTO(c.Name, c.Price, c.Isbooking, c.Idroom);

            string       commandText         = "AddRooms";
            SqlParameter sqlParametersIDRoom = new SqlParameter("@IDRoom", SqlDbType.Int)
            {
                Value = b.Idroom
            };

            SqlParameter sqlParametersName = new SqlParameter("@Name", SqlDbType.NVarChar, 50)
            {
                Value = Convert.ToString(b.Name)
            };

            SqlParameter sqlParametersTypePrice = new SqlParameter("@Price", SqlDbType.Decimal)
            {
                Value = (b.Price)
            };
            SqlParameter sqlParametersTypeStatuss = new SqlParameter("@Statuss", SqlDbType.Bit)
            {
                Value = b.Isbooking
            };

            return(SqlHelper.Instance.ExecuteNonQuery(commandText, CommandType.StoredProcedure, sqlParametersIDRoom, sqlParametersName, sqlParametersTypePrice, sqlParametersTypeStatuss));
        }
示例#2
0
        public async Task <string> CreateRoomAsync(RoomsDTO roomData)
        {
            var response = await _client.PostAsJsonAsync(nameof(RoomsController.CreateRoom), roomData);

            if (response.IsSuccessStatusCode)
            {
                var message = await response.Content.ReadAsStringAsync();

                return(message);
            }

            return(null);
        }
示例#3
0
        public IActionResult CreateRoom(RoomsDTO room)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                var entity = _mapper.Map <Rooms>(room);
                _context.Rooms.Add(entity);
                _context.SaveChanges();

                return(Ok(entity.RoomName));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
 public IActionResult Insert([FromBody] RoomsDTO dto)
 {
     try
     {
         var model = mapper.Map <Rooms>(dto);
         if (model != null)
         {
             repository.Insert(model);
             var result = repository.SaveChanges();
             if (result)
             {
                 return(Ok());
             }
         }
         return(NotFound());
     }
     catch (System.Exception msg)
     {
         return(NotFound(msg));
     }
 }