예제 #1
0
 public IActionResult Create([Bind("RoomNumber, FloorNumber, RoomTypeId, HotelId")] CreateRoomVM room)
 {
     if (IRoomService.AddRoom(room))
     {
         return(RedirectToAction("Index"));
     }
     return(View());
 }
예제 #2
0
        public IEnumerable <Room> AddRoom([FromBody] IEnumerable <Room> data)
        {
            TempRoomId.Clear();
            var result = _service.AddRoom(data, TempRoomId);

            TempRoomId.Append(result.ToList()[0].TempRoomID);
            return(result);
        }
예제 #3
0
        public async Task CreateNewRoomAsync(string roomName, int maxCount)
        {
            var roomId = roomService.AddRoom(roomName, maxCount, connectedUsers[Context.ConnectionId]);

            JoinRoomAsync(roomId).Wait();
            //After created room update of all users pages
            await Clients.Group("MainGroup").SendAsync("UpdateRoomList");
        }
        public ActionResult AddRoom([FromBody] String JSONString)
        {
            String JSONContent = StringToJSONFormat(JSONString);

            RoomDTO room = JsonConvert.DeserializeObject<RoomDTO>(JSONContent);
            Model.Manager.Room newRoom = new Model.Manager.Room((int)room.Id, (TypeOfUsage)room.Usage, 0, 0, false);
            _roomService.AddRoom(newRoom);
            return Ok();
        }
 public IActionResult Create(RoomViewModel model)
 {
     if (ModelState.IsValid)
     {
         roomService.AddRoom(model);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(model));
 }
        public IActionResult AddRoom([FromBody]RoomObject room)
        {
            if (room != null)
            {
                _service.AddRoom(room);
            }

            return Ok();
        }
예제 #7
0
 public IActionResult Create([Bind("RoomId,RoomNumber,RoomType,RoomSize,Price,EntranceAvailableDate")] RoomDetailViewModel room)
 {
     if (ModelState.IsValid)
     {
         _roomService.AddRoom(room);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(room));
 }
예제 #8
0
 public IActionResult AddRoom([FromBody] Room room)
 {
     room.DateModified = DateTime.Today;
     room.DateCreated  = DateTime.Today;
     if (room != null)
     {
         _service.AddRoom(room);
     }
     return(Ok());
 }
        public ActionResult AddRoom(RoomDto dto)
        {
            var result = m_roomService.AddRoom(dto);

            if (result.IsFailure)
            {
                return(BadRequest());
            }

            return(Ok());
        }
예제 #10
0
 public async Task <IActionResult> Create([Bind("RoomId,RoomNumber,RoomType,RoomSize,Price,EntranceAvailableDate")] RoomDetailViewModel room)
 {
     if (ModelState.IsValid)
     {
         _roomService.AddRoom(room);
         ViewBag.Message = $"The room number {room.RoomNumber} has created succesfully!";
         ViewBag.Succes  = 1;
         return(View(nameof(Index), await _roomService.AllRooms()));
     }
     return(View(room));
 }
예제 #11
0
 public void CreatePrivateTalk(String name)
 {
     if (!string.IsNullOrEmpty(name))
     {
         User guest = _userService.FindUserByNickname(name);
         if (guest != null)
         {
             string userStr = HttpContext.Session.GetString("user");
             if (userStr != null)
             {
                 Room room = new Room();
                 room.Owner = JsonConvert.DeserializeObject <User>(userStr).Uid;
                 room.Type  = "private";
                 room.Name  = name;
                 room.Guest = guest.Uid;
                 _roomService.AddRoom(room);
             }
             Response.Redirect("/chatRoom", false);
         }
     }
 }
 public IActionResult Room([FromBody] MvRoom room)
 {
     try
     {
         int roomId = roomService.AddRoom(room);
         return(Ok(roomId));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
예제 #13
0
        // POST: api/Rooms
        public IHttpActionResult PostRoom([FromBody] RoomView room)
        {
            var model  = _mapper.MapRoomViewToRoom(room);
            var result = _service.AddRoom(model);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(InternalServerError());
            }
        }
예제 #14
0
        public void AddRoom()
        {
            Room room = new Room();

            Console.WriteLine("Print RoomTypeId: ");
            room.RoomTypeId = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Print RoomStatusId: ");
            room.RoomStatusId = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Print RoomNumber: ");
            room.RoomNumber = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Print MaxPerson: ");
            room.MaxPerson = Int32.Parse(Console.ReadLine());
            roomService.AddRoom(room);
            presenter.Presenter(roomService.ReadRooms());
        }
예제 #15
0
        public async Task <IActionResult> Create(RoomInputModel createModel)
        {
            if (!await roomService.IsRoomNumberFree(createModel.Number))
            {
                ModelState.AddModelError(nameof(createModel.Number), "Room with this number alreay exists");
            }

            if (createModel.UseSamePhoto)
            {
                ModelState.AddModelError("Error", "Error parsing your request");
            }
            else if (createModel.PhotoUpload != null)
            {
                var timestamp = $"{DateTime.Today.Day}-{DateTime.Today.Month}-{DateTime.Today.Year}";
                var fileName  = $"_{timestamp}_HMS_RoomPhoto";

                IFormFile file = createModel.PhotoUpload;

                using var stream = new MemoryStream();
                await file.CopyToAsync(stream);

                var photoUrl = await imageManager.UploadImageAsync(stream, fileName);

                if (string.IsNullOrWhiteSpace(photoUrl) || photoUrl.StartsWith("Error"))
                {
                    ModelState.AddModelError(nameof(createModel.PhotoUpload), $"An error occured: {photoUrl}.");
                    return(this.View(createModel));
                }

                var room = new Room
                {
                    Capacity      = createModel.Capacity,
                    AdultPrice    = createModel.AdultPrice,
                    ChildrenPrice = createModel.ChildrenPrice,
                    Type          = createModel.Type,
                    Number        = createModel.Number,
                    ImageUrl      = photoUrl,
                };

                await roomService.AddRoom(room);

                return(RedirectToAction(nameof(Index)));
            }

            ModelState.AddModelError(nameof(createModel.PhotoUpload), "Image is required. Upload one.");
            return(this.View(createModel));
        }
예제 #16
0
        public async Task <ActionResult <Room> > PostRoom(Room room)
        {
            try
            {
                await _service.AddRoom(room);
            }
            catch (RoomAlreadyExistsException e)
            {
                return(Conflict(e));
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(CreatedAtAction("GetRooms", new { number = room.Number }, room));
        }
예제 #17
0
        public async Task <ActionResult> AddRoom([FromBody] AddRoomRequest model)
        {
            System.Console.WriteLine("add room cont");

            if (!ModelState.IsValid)
            {
                return(HttpBadRequest());
            }

            if (model.parent_id != null)
            {
                if (await _roomService.GetById(new ObjectId(model.parent_id)) == null)
                {
                    return(HttpNotFound(string.Format("No room with id '{0}' exists.", model.parent_id)));
                }
            }

            var roomId = await _roomService.AddRoom(model);

            Response.Headers["Location"] = string.Format("/api/rooms/{0}", roomId);
            return(new HttpStatusCodeResult((int)HttpStatusCode.Created));
        }
        public IActionResult AddRoom([FromBody] RoomDto room)
        {
            Result result = roomService.AddRoom(room);

            if (result.Success)
            {
                return(Ok(result.Id));
            }
            else
            {
                if (result.Exception != null)
                {
                    Log.Error(result.Exception, "Error adding room to database!");
                    return(StatusCode(500));
                }
                else
                {
                    Log.Warning("Unable to add room to database!");
                    return(Conflict());
                }
            }
        }
예제 #19
0
        public async Task <IActionResult> CreateRoom(Room room)
        {
            var createdRoom = await _roomService.AddRoom(room);

            return(Ok(createdRoom));
        }
예제 #20
0
        public RoomMutation(IRoomService roomService)
        {
            Name        = "RoomMutation";
            Description = "这里主要包含了修改房间状态等功能";

            FieldAsync <BooleanGraphType>(
                "changeRoomStatus",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            },
                    new QueryArgument <NonNullGraphType <RoomStatusEnum> > {
                Name = "status"
            }
                    ),
                resolve: async context =>
            {
                var roomId = context.GetArgument <int>("roomId");
                var status = context.GetArgument <RoomStatus>("status");
                var userId = UserHelpers.GetUserIdFromContext(context.UserContext);

                return(await roomService.ChangeRoomStatus(roomId, userId, status));
            }).AuthorizeWith(Policy.WaiterPolicy);

            FieldAsync <BooleanGraphType>(
                "deleteRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            }
                    ),
                resolve: async context =>
            {
                var roomId = context.GetArgument <int>("roomId");
                return(await roomService.DeleteRoomById(roomId));
            }
                ).AuthorizeWith(Policy.AdminPolicy);

            FieldAsync <BooleanGraphType>(
                "createRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <RoomInputType> > {
                Name = "room"
            }
                    ),
                resolve: async context =>
            {
                var room = context.GetArgument <Room>("room");
                return(await roomService.AddRoom(room));
            }
                ).AuthorizeWith(Policy.AdminPolicy);

            FieldAsync <BooleanGraphType>(
                "updateRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            },
                    new QueryArgument <NonNullGraphType <RoomInputType> > {
                Name = "room"
            }
                    ),
                resolve: async context =>
            {
                var room   = context.GetArgument <Room>("room");
                var roomId = context.GetArgument <int>("roomId");
                room.Id    = roomId;

                return(await roomService.UpdateRoomInfo(room));
            }
                ).AuthorizeWith(Policy.AdminPolicy);
        }
예제 #21
0
        public async Task <IActionResult> AddRoom([FromBody] RoomModel room)
        {
            var newRoom = await _roomService.AddRoom(RoomMapper.Map(room));

            return(Ok(newRoom));
        }
        public async Task <IActionResult> AddRoom([FromBody] Room room)
        {
            var addRooms = await _roomService.AddRoom(room);

            return(Ok(addRooms));
        }
        public async Task <IActionResult> Add(int hotelId, Room room)
        {
            await roomService.AddRoom(hotelId, room);

            return(RedirectToAction(nameof(HotelsController.Hotel), "Hotels", new { id = hotelId }));
        }
예제 #24
0
        public IActionResult Create(Room room)
        {
            _roomService.AddRoom(room);

            return(Redirect("/Room/Index"));
        }
예제 #25
0
        //[Authorize(Roles = "admin")]
        public async Task <IActionResult> AddRoom([FromBody] AddRoom addRoom)
        {
            await _roomService.AddRoom(addRoom.Name, addRoom.NumberOfRows, addRoom.NumberOfSeatsInRow);

            return(Ok());
        }
예제 #26
0
        public async Task <IActionResult> AddRoom([FromBody] RoomModel admin)
        {
            var name = await _roomService.AddRoom(RoomMapper.Map(admin));

            return(Ok(name));
        }
예제 #27
0
        public async Task <IActionResult> AddRoom([FromBody] Room room, [FromRoute] string uid)
        {
            await _roomService.AddRoom(room, uid);

            return(NoContent());
        }
예제 #28
0
 public async Task <int> AddRoom(RoomModel roomModel) =>
 await _service.AddRoom(roomModel);