public ActionResult DeleteConfirmed(int id) { ApplicationDbContext.Events events = db.DbEvents.Find(id); db.DbEvents.Remove(events); db.SaveChanges(); return(RedirectToAction("Index")); }
//[RoleAllow("Admin")] public ActionResult Edit([Bind(Include = "uId,eventId,etDept,title,startt,endt,dtCreated,proCustomer,allDay,color,startTime,endTime,eDesc,trigPerson,SONo,SoStatus,soCopy,nowAtStatn,partNo,comments,EventsStatus,backgColor,borderColor,textColor,JoNo,PoNo,TotpartNo")] ApplicationDbContext.Events events) { if (ModelState.IsValid) { db.Entry(events).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(events)); }
// GET: Events/Edit/5 //[RoleAllow("Admin")] public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationDbContext.Events events = db.DbEvents.Find(id); if (events == null) { return(HttpNotFound()); } return(View(events)); }
//[RoleAllow("Sales","Admin")] public ActionResult Create([Bind(Include = "uId,eventId,etDept,title,startt,endt,dtCreated,proCustomer,allDay,color,startTime,endTime,eDesc,trigPerson,SONo,SoStatus,soCopy,nowAtStatn,partNo,comments,EventsStatus,backgColor,borderColor,textColor,JoNo,PoNo,TotpartNo")] ApplicationDbContext.Events events, FormCollection fc, ManageBothViewModel mvb) { if (ModelState.IsValid) { ///Date and time calculation here before adding the event with reqd time and expected delivery date ///Start date -> last end datetime + 1 min ///End date -> according to order details if (mvb.FileUploadModel.soCopyData.ContentLength > 0) { /// var fileName = Path.GetFileName(files.FileName); /// var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); /// files.SaveAs(path); /// /// Save to FileUploadEvents /// String FileExt = Path.GetExtension(files.FileName).ToUpper(); FileUploadService fus = new FileUploadService(); var ele = mvb.SoNoEventds.MultiplePartNo.Count(); var sbc = new ApplicationDbContext.SoNosEvent(); if (mvb.Events.SONo != null) { sbc.id = mvb.Events.eventId; sbc.SoNo = mvb.Events.SONo; // foreach (var i in ele) for (int i = 0; i < ele; i++) { if (mvb.SoNoEventds.MultiplePartNo != null) { sbc.AddNewPartNo = true; sbc.uUid = events.uId; sbc.MultiplePartNo = mvb.SoNoEventds.MultiplePartNo[i]; sbc.MultiplePartQtyNo = mvb.SoNoEventds.MultiplePartQtyNo[i]; sbc.SoNo = mvb.Events.SONo; db.SoNosEvents.Add(sbc); db.SaveChanges(); } } } String FileExt = Path.GetExtension(mvb.FileUploadModel.soCopyData.FileName).ToUpper(); if (FileExt == ".PDF") { Stream str = mvb.FileUploadModel.soCopyData.InputStream; BinaryReader Br = new BinaryReader(str); Byte[] FileDet = Br.ReadBytes((Int32)str.Length); FileUploadEvents Fd = new Models.ApplicationDbContext.FileUploadEvents(); Fd.soCopyType = mvb.FileUploadModel.soCopyData.ContentType; Fd.soNoRef = events.SONo; Fd.soCopyData = FileDet; Fd.soCopyId = events.eventId; Fd.soEventId = events.uId; events.TotpartNo = ele; events.SoNosEvent = sbc; db.DbFileUpload.Add(Fd); // db.SoNosEvents.Add(sbc); db.DbEvents.Add(events); db.SaveChanges(); ViewBag.EventStatus = events.eventId; return(RedirectToAction("CalendarView")); } //var tempvar = int.TryParse(fus._incrementer.ToString(), out int somTemp); // events.soCopy = Session[""].ToString(); return(RedirectToAction("CalendarView")); } else { ModelState.AddModelError(String.Empty, "Invalid format for Uploaded file. Use only PDF formats"); return(View()); // return } // FileUploadService fuservice = new FileUploadService(); // foreach(var item in FileUploadModel.files) // { // fuservice.SaveFileDetails(item); // } } else { var errors = ModelState.Values.SelectMany(v => v.Errors); ModelState.AddModelError(String.Empty, "Username already in use"); } return(View("CalendarView")); }