public async Task <object> CreateReservationNotification(ReservationNotification notification, string initiatorEmail)
        {
            ReservationNotification Notification;

            try
            {
                Notification = new ReservationNotification()
                {
                    UserEmailFrom = notification.UserEmailFrom,
                    UserEmailTo   = notification.UserEmailTo,
                    ReservationId = notification.ReservationId,
                    Message       = notification.Message,
                    Status        = 0,
                };

                if (initiatorEmail == Notification.UserEmailTo)
                {
                    return(HttpStatusCode.OK);
                }
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(HttpStatusCode.BadRequest);
            }

            await _context.ReservationNotification.AddAsync(Notification);

            await _context.SaveChangesAsync();

            return(Notification);
        }
示例#2
0
        public async Task <object> CreateReservationNotification(ReservationNotification reservation)
        {
            string userID    = User.Claims.FirstOrDefault(c => c.Type == "UserID").Value;
            var    initiator = await _userManager.FindByEmailAsync(userID);

            return(await _notificationService.CreateReservationNotification(reservation, initiator.Email));
        }