예제 #1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var msg = new Message {
                Name = Name,
                Msg  = Message
            };

            _messagesService.AddMessage(msg);

            return(Page());
        }
예제 #2
0
        public IActionResult Create(int id, [FromQuery] Reservation reservation)
        {
            reservation.RoomId = id;
            reservation        = _reservationService.IncludeRoom(reservation);
            if (reservation.Room == null)
            {
                _messageService.AddMessage(new Message("The room was not found."));
                return(RedirectToAction("Index", "Room"));
            }

            //Since the default (of timespan) values are the same, they can never be different
            if (!_reservationService.HasValidRange(reservation))
            {
                _messageService.AddMessage(new Message("Invalid time range."));
                return(RedirectToAction("Prepare", reservation));
            }

            return(View(reservation));
        }
예제 #3
0
 public IActionResult PostMessage([FromForm] MessageData messageData)
 {
     _messagesService.AddMessage(messageData.Name, messageData.LastName, messageData.Message);
     return(PartialView("_MessagePostedPartial"));
 }
 public void GenerateMessage()
 {
     _messagesService.AddMessage(Guid.NewGuid().ToString("N"));
 }
예제 #5
0
        public ActionResult <Message> Post([FromBody] Message message)
        {
            var response = _messagesService.AddMessage(message);

            return(response);
        }