public ActionResult DeleteConfirmed(int id) { EventsPhotography eventsPhotography = db.EventsPhotographies.Find(id); db.EventsPhotographies.Remove(eventsPhotography); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "EventsPhotographyID,ClientOrderID,Category,NumberOfTeam,Price")] EventsPhotography eventsPhotography) { if (ModelState.IsValid) { db.Entry(eventsPhotography).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientOrderID = new SelectList(db.ClientOrders, "ClientOrderID", "ClientOrderKey", eventsPhotography.ClientOrderID); return(View(eventsPhotography)); }
// GET: EventsPhotographie/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EventsPhotography eventsPhotography = db.EventsPhotographies.Find(id); if (eventsPhotography == null) { return(HttpNotFound()); } return(View(eventsPhotography)); }
// GET: EventsPhotographie/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EventsPhotography eventsPhotography = db.EventsPhotographies.Find(id); if (eventsPhotography == null) { return(HttpNotFound()); } ViewBag.ClientOrderID = new SelectList(db.ClientOrders, "ClientOrderID", "ClientOrderKey", eventsPhotography.ClientOrderID); return(View(eventsPhotography)); }
public JsonResult Create(ClientOrderViewModel vm) { ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName"); ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name"); ViewBag.EventSubTypeID = new SelectList(db.EventSubTypes, "EventSubTypeID", "EventSubTypeName"); ViewBag.EventTypeID = new SelectList(db.EventTypes, "EventTypeID", "EventTypeName"); ViewBag.VenueID = new SelectList(db.Venues, "VenueID", "VenueName"); ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "ServiceName"); ViewBag.ServiceProviderID = new SelectList(db.ServiceProviders, "ServiceProviderID", "ServiceProviderName"); bool status = false; if (ModelState.IsValid) { EventServices evs = new EventServices(); ClientOrder co = new ClientOrder(); co.ClientID = vm.ClientID; co.CityID = vm.CityID; co.EventTypeID = vm.EventTypeID; co.EventSubTypeID = vm.EventSubTypeID; co.EventName = vm.EventName; co.EventStartDate = vm.EventStartDate; co.EventEndDate = vm.EventEndDate; co.NoOfGuest = vm.NoOfGuest; if (vm.VenueID != 0) { co.VenueID = Convert.ToInt32(vm.VenueID); } co.SpecialInstruction = vm.SpecialInstruction; co.Date = DateTime.Now.Date; db.ClientOrders.Add(co); db.SaveChanges(); int latestCoId = co.ClientOrderID; if (vm.VenueID != 0) { evs.ClientOrderID = latestCoId; evs.ServiceID = 9; evs.Price = Convert.ToDouble(db.Venues.Where(e => e.VenueID == vm.VenueID).Select(rent => rent.Rent).FirstOrDefault()); db.EventServicess.Add(evs); db.SaveChanges(); } EventSchedule es = new EventSchedule(); es.EventName = vm.EventName; es.EventStartDate = vm.EventStartDate; es.EventEndDate = vm.EventEndDate; es.VenueID = Convert.ToInt32(vm.VenueID); db.EventSchedules.Add(es); db.SaveChanges(); if (vm.PgCategory != null) { EventsPhotography ep = new EventsPhotography(); ep.Category = Convert.ToInt32(vm.PgCategory); ep.NumberOfTeam = Convert.ToInt32(vm.PgNumberOfTeam); ep.Price = Convert.ToDouble(vm.PgPrice); ep.ClientOrderID = latestCoId; db.EventsPhotographies.Add(ep); db.SaveChanges(); evs.ClientOrderID = latestCoId; evs.ServiceID = 7; evs.Price = Convert.ToDouble(vm.PgPrice); db.EventServicess.Add(evs); db.SaveChanges(); } if (vm.EventsDecorations != null) { foreach (var item in vm.EventsDecorations) { EventsDecoration evDec = new EventsDecoration(); evDec.ClientOrderID = latestCoId; evDec.DecorationTypeID = item.DecorationTypeID; if (item.DecorationImageID != null) { evDec.DecorationImageID = item.DecorationImageID; } if (item.CustomImage != null) { evDec.CustomImage = item.CustomImage; } evDec.Price = item.Price; db.EventsDecorations.Add(evDec); } evs.ClientOrderID = latestCoId; evs.ServiceID = 6; evs.Price = Convert.ToDouble(vm.TotalDecCost); db.SaveChanges(); } if (vm.EventsCaterings != null) { foreach (var item in vm.EventsCaterings) { EventsCatering ecate = new EventsCatering(); ecate.ClientOrderID = latestCoId; ecate.MealType = item.MealType; ecate.FoodItems = item.FoodItems; ecate.PerPersonCost = item.PerPersonCost; ecate.TotalCost = item.PerPersonCost * vm.NoOfGuest; db.EventsCaterings.Add(ecate); } evs.ClientOrderID = latestCoId; evs.ServiceID = 5; evs.Price = Convert.ToDouble(vm.TotalCateCost * vm.NoOfGuest); db.SaveChanges(); } if (vm.EventServicess != null) { foreach (var i in vm.EventServicess) { EventServices eser = new EventServices(); eser.ClientOrderID = latestCoId; eser.ServiceID = i.ServiceID; eser.Price = i.Price; db.EventServicess.Add(eser); } db.SaveChanges(); } var subTotal = db.EventServicess.Where(e => e.ClientOrderID == latestCoId).Sum(s => s.Price); if (subTotal != 0) { EventBill ebill = new EventBill(); ebill.ClientOrderID = latestCoId; ebill.SubTotalAmount = Convert.ToDouble(subTotal); ebill.MadeBy = User.Identity.GetUserName(); ebill.vat = vm.Vat; ebill.Discount = Convert.ToInt32(vm.Discount); db.EventBills.Add(ebill); db.SaveChanges(); EventPayment epay = new EventPayment(); epay.ClientOrderID = latestCoId; epay.Total = vm.NetTotal; epay.PaidAmount = 0; db.EventPayments.Add(epay); db.SaveChanges(); } status = true; } else { status = false; } var errors = ModelState.Values.SelectMany(v => v.Errors); return(Json(status, JsonRequestBehavior.AllowGet)); }