예제 #1
0
        public async Task <ActionResult> DeleteReservation(int?resId)
        {
            if (resId != null)
            {
                var id = await rep.GetReservationByIdAsync((int)resId);

                await rep.DeleteReservationAsync((int)resId);

                return(RedirectToAction("ShowInfo", new { id = id.RoomId, state = "deleted" }));
            }
            return(RedirectToAction("ShowInfo"));
        }
예제 #2
0
        public async Task <ActionResult> DeleteReservation(int?resId)
        {
            if (resId != null)
            {
                var reservation = await rep.GetReservationByIdAsync((int)resId);

                if (reservation.UserStringId == User.Identity.GetUserId())
                {
                    await rep.DeleteReservationAsync((int)resId);

                    ViewBag.Result = "Deleted";
                    return(RedirectToAction("ShowInfo", new { id = reservation.RoomId }));
                }
                ViewBag.Error = "You are not an owner of this reservation";
                return(RedirectToAction("ShowInfo", new { id = reservation.RoomId }));
            }
            return(RedirectToAction("ShowInfo"));
        }