public ActionResult Approve(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReservationsModels reservationsModels = db.ReservationsModels.Find(id); if (reservationsModels.approved == false) { reservationsModels.approved = true; db.SaveChanges(); var newApprovedReservation = new ApprovedReservationsModels(); newApprovedReservation.User = reservationsModels.User; newApprovedReservation.Date = reservationsModels.Date; newApprovedReservation.Reason = reservationsModels.Reason; newApprovedReservation.Phone = reservationsModels.Phone; newApprovedReservation.LocationReserved = reservationsModels.LocationReserved; db.ApprovedReservationsModels.Add(newApprovedReservation); db.SaveChanges(); var newCostsModels = new CostsModels(); newCostsModels.UserName = reservationsModels.User; newCostsModels.Date = reservationsModels.Date; newCostsModels.Amount = 200; newCostsModels.Month = reservationsModels.Date; newCostsModels.EventId = 0; newCostsModels.EventName = reservationsModels.Reason; db.CostsModels.Add(newCostsModels); db.SaveChanges(); var newPaymentsModelss = new PaymentsModels(); newPaymentsModelss.UserName = reservationsModels.User; newPaymentsModelss.Date = DateTime.Now; newPaymentsModelss.Amount = 400; newPaymentsModelss.Month = DateTime.Now; newPaymentsModelss.Member = false; db.PaymentsModels.Add(newPaymentsModelss); db.SaveChanges(); string redirectUrlInside = "/Reservations/Index/"; return(Redirect(redirectUrlInside)); } string redirectUrl = "/Reservations/Index/"; return(Redirect(redirectUrl)); }
public ActionResult BookLocationForEvent(int id, int locationId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (locationId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EventsModels eventsModels = db.EventsModels.Find(id); if (eventsModels == null) { return(HttpNotFound()); } eventsModels.LocationId = locationId; eventsModels.LocationName = db.LocationsModels.Find(locationId).Name; db.SaveChanges(); var newApprovedReservation = new ApprovedReservationsModels(); newApprovedReservation.User = eventsModels.CreationUser; newApprovedReservation.Date = eventsModels.EventDate; newApprovedReservation.Reason = eventsModels.Name; newApprovedReservation.Phone = " "; newApprovedReservation.LocationReserved = eventsModels.LocationId; db.ApprovedReservationsModels.Add(newApprovedReservation); db.SaveChanges(); var newCostsModels = new CostsModels(); newCostsModels.UserName = eventsModels.CreationUser; newCostsModels.Date = DateTime.Now; newCostsModels.Amount = 200; newCostsModels.Month = eventsModels.EventDate; newCostsModels.EventId = eventsModels.Id; newCostsModels.EventName = eventsModels.Name; db.CostsModels.Add(newCostsModels); db.SaveChanges(); string redirectUrl = "/Events"; return(Redirect(redirectUrl)); }