public ActionResult Process(int ID = 0) { Models.MSTR_NOC NOC = ctx.MSTR_NOC.Where(w => w.NocApplicationID == ID).FirstOrDefault(); if (NOC == null) return HttpNotFound(); ViewModel.MSTR_NOC_Ext _noc = new ViewModel.MSTR_NOC_Ext(NOC); return View(_noc); }
public ActionResult Process(int ID, List<NOC_Details> NocDetails) { Models.MSTR_NOC NOC = ctx.MSTR_NOC.Where(w => w.NocApplicationID == ID).FirstOrDefault(); if (NOC == null) return HttpNotFound(); foreach (Models.NOC_Details Details in NocDetails) { NOC_Details dbNocDetails = ctx.NOC_Details.Where(w => w.NocID == Details.NocID).FirstOrDefault(); if (dbNocDetails != null) { dbNocDetails.MaxAltitude = Details.MaxAltitude; dbNocDetails.NocBuffer = Details.NocBuffer; dbNocDetails.Status = Details.Status.Trim(); dbNocDetails.StatusChangedBy = Util.getLoginUserID(); dbNocDetails.StatusChangedOn = DateTime.UtcNow; dbNocDetails.Coordinates = Details.Coordinates; ctx.Entry(dbNocDetails).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } } NOC.StartDate = NOC.NOC_Details.Min(m => m.StartDate); NOC.EndDate = NOC.NOC_Details.Max(m => m.EndDate); NOC.CountAmended = NOC.NOC_Details.Where(w => w.Status == "Amended").Count(); NOC.CountApproved = NOC.NOC_Details.Where(w => w.Status == "Approved").Count(); NOC.CountRejected = NOC.NOC_Details.Where(w => w.Status == "Rejected").Count(); NOC.CountNew = NOC.NOC_Details.Where(w => w.Status == "New").Count(); ctx.Entry(NOC).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); return RedirectToAction("View", new { ID = ID }); }
public async Task<ActionResult> Register(Models.MSTR_NOC NOC) { StringBuilder SB = new StringBuilder(); ViewBag.DbErrors = ""; NOC.CreateBy = Util.getLoginUserID(); NOC.CreatedOn = DateTime.UtcNow; if (NOC.FlightType == "0") NOC.FlightType = Request.Form["FlightTypeOther"]; NOC.NocName = NOC.FlightType + " for " + NOC.FlightFor; NOC.AccountID = Util.getAccountID(); foreach (var noc in NOC.NOC_Details) { noc.Status = "New"; if (noc.PilotID == 0) noc.PilotID = Util.getLoginUserID(); noc.StatusChangedBy = Util.getLoginUserID(); noc.StatusChangedOn = DateTime.UtcNow; noc.OuterCoordinates = noc.Coordinates; noc.NocBuffer = 50; } NOC.CreatedOn = DateTime.UtcNow; //find out total count and update the master var NocCount = NOC.NOC_Details.Count(); NOC.CountTotal = NocCount; NOC.CountNew = NocCount; NOC.CountApproved = 0; NOC.CountRejected = 0; NOC.CountAmended = 0; NOC.StartDate = NOC.NOC_Details.Min(m => m.StartDate); NOC.EndDate = NOC.NOC_Details.Max(m => m.EndDate); try { ctx.MSTR_NOC.Add(NOC); await ctx.SaveChangesAsync(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { SB.AppendLine($"Entity of type '{eve.Entry.Entity.GetType().Name}' in state '{eve.Entry.State}'<br>"); foreach (var ve in eve.ValidationErrors) { SB.AppendLine($" - '{ve.PropertyName}' -> '{ve.ErrorMessage}'<br>"); } } } catch (DbUpdateException e) { foreach (var eve in e.Entries) { SB.AppendLine($"Entity of type '{eve.Entity.GetType().Name}' in state '{eve.State}'<br>"); } } if (SB.Length > 0) { ViewBag.DbErrors = SB.ToString(); return View(NOC); } return RedirectToAction("View", new { ID = NOC.NocApplicationID }); }//public ActionResult Register(Models.MSTR_NOC NOC)
// GET: NOC public ActionResult Register(int ID = 0) { ViewBag.DbErrors = ""; //to create gcaapproval if (!exLogic.User.hasAccess("FLIGHT.SETUP") && !exLogic.User.hasAccess("NOC.REGISTER")) return RedirectToAction("NoAccess", "Home"); var NOC = new Models.MSTR_NOC(); if (ID != 0) { NOC = ctx.MSTR_NOC.Where(w => w.NocApplicationID == ID).FirstOrDefault(); } if (NOC.NOC_Details.Count == 0) NOC.NOC_Details.Add(new Models.NOC_Details() { StartDate = DateTime.Now, EndDate = DateTime.Now, StartTime = new TimeSpan(6, 0, 0), EndTime = new TimeSpan(18, 0, 0), MaxAltitude = 40, MinAltitude = 0 }); return View(NOC); }
public ActionResult ViewNocApplication3D([Bind(Prefix = "ID")]int NocApplicationID = 0) { Models.MSTR_NOC NOC = ctx.MSTR_NOC.Where(w => w.NocApplicationID == NocApplicationID).FirstOrDefault(); if (NOC == null) return HttpNotFound(); return View(NOC); }