public ActionResult RemoveConfirmed(int id) { MileageForm mileageForm = db.MileageForms.Find(id); db.Entry(mileageForm).State = EntityState.Modified; mileageForm.IsRemoved = true; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: MileageForms/Create public ActionResult Create() { MileageForm mileageForm = new MileageForm { Date = DateTime.Now, StaffMemberID = db.Staff.Where(s => s.Email == User.Identity.Name).SingleOrDefault().ID, FormStatusID = db.FormStatus.Where(f => f.StatusType == "Pending").SingleOrDefault().ID }; db.MileageForms.Add(mileageForm); db.SaveChanges(); return(RedirectToAction("Details", new { id = mileageForm.ID })); }
// GET: MileageForms/Delete/5 public ActionResult Remove(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MileageForm mileageForm = db.MileageForms.Find(id); if (mileageForm == null) { return(HttpNotFound()); } return(View(mileageForm)); }
public IActionResult SubmitMileage([FromBody] PWAMileage submittedform) { var dbutil = new FormToDbUtil(_subcontext, _context); MileageForm mf = dbutil.PopulateMileage(submittedform); var submission = _subcontext; submission.Add(mf); submission.SaveChanges(); // Do something with form Response.Headers.Add("Access-Control-Allow-Origin", "*"); Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); return(Json(new { response = "ok" })); }
public void TenRowTimesheet() { string path = TestContext.CurrentContext.TestDirectory + @"\FormSubmit\TenRowMileagesheet.json"; if (!File.Exists(path)) { System.Console.WriteLine(path); Assert.IsTrue(false); } string k = File.ReadAllText(path).Replace("\r", ""); MileageForm obj = new MileageForm(); obj.clientName = "Donald Duck"; obj.prime = "123456"; obj.providerName = "Daughy Duck"; obj.providerNum = "654321"; obj.brokerage = "Not sure"; obj.scpaName = "SC/PA"; obj.serviceAuthorized = "All"; obj.addMileRow("2020-03-20", "10", "true", "driving"); obj.addMileRow("2020-03-21", "10", "true", "driving"); obj.addMileRow("2020-03-22", "10", "true", "driving"); obj.addMileRow("2020-03-23", "10", "true", "driving"); obj.addMileRow("2020-03-24", "10", "true", "driving"); obj.addMileRow("2020-03-25", "10", "true", "driving"); obj.addMileRow("2020-03-26", "10", "true", "driving"); obj.addMileRow("2020-03-27", "10", "true", "driving"); obj.addMileRow("2020-03-28", "10", "true", "driving"); obj.addMileRow("2020-03-29", "10", "true", "driving"); obj.totalMiles = "100"; obj.serviceGoal = "Drive them"; obj.progressNotes = "Well behaved"; obj.employerSignature = true; obj.employerSignDate = "2020-04-01"; obj.authorization = true; obj.approval = true; obj.providerSignature = true; obj.providerSignDate = "2020-04-01"; // Due to Windows adding \r for newlines we remove these, and for whatever reason Windows // Also adds a newline at the end of the file even if it doesn't exist, so we add that. string j = JsonConvert.SerializeObject(obj, Formatting.Indented).Replace("\r", "") + "\n"; Assert.IsTrue(String.Equals(j, k)); }
// POST: MileageForms/Create // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include = "ID,Date,FormStatusID,StaffMemberID,ConferenceFormID,CreatedBy,CreatedOn,UpdatedBy,UpdatedOn,RowVersion")] MileageForm mileageForm) //{ // try // { // if (ModelState.IsValid) // { // mileageForm.StaffMemberID = db.Staff.Where(s => s.Email == User.Identity.Name).SingleOrDefault().ID; // mileageForm.FormStatusID = db.FormStatus.Where(f => f.StatusType == "Pending").SingleOrDefault().ID; // db.MileageForms.Add(mileageForm); // db.SaveChanges(); // return RedirectToAction("Details", new { id = mileageForm.ID }); // } // } // catch (RetryLimitExceededException) // { // ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator."); // } // catch (DataException) // { // ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); // } // return View(mileageForm); //} // GET: MileageForms/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MileageForm mileageForm = db.MileageForms.Find(id); if (mileageForm == null) { return(HttpNotFound()); } if (User.IsInRole("Admin")) { FormStatusDropDown(mileageForm); } return(View(mileageForm)); }
public void EmptyMileagesheetTest() { string path = TestContext.CurrentContext.TestDirectory + @"\FormSubmit\emptyMileagesheet.json"; if (!File.Exists(path)) { Console.WriteLine(path); Assert.IsTrue(false); } string k = File.ReadAllText(path).Replace("\r", ""); var obj = new MileageForm(); //// Due to Windows adding \r for newlines we remove these, and for whatever reason Windows //// Also adds a newline at the end of the file even if it doesn't exist, so we add that. string j = JsonConvert.SerializeObject(obj, Formatting.Indented).Replace("\r", "") + "\n"; Assert.IsTrue(String.Equals(j, k)); }
// Convert the timesheet form row items into timesheet time entries. Makes // certain assumptions about start times, end times, and group. private void PopulateMileageEntries(PWAMileage m, MileageForm mf) { mf.TotalMiles = Convert.ToDouble(convUtil.TimeToDecimal(m.totalMiles.value)); var tl = new List <MileageEntry>(); // Only update if true if (m.mileagesheet.wasEdited == true) { mf.Edited = true; } foreach (var row in m.mileagesheet.value) { var x = new MileageEntry(); try { x.Date = Convert.ToDateTime(row.date); } catch (FormatException) { x.Date = DateTime.Now; } try { x.Miles = float.Parse(row.totalMiles); } catch (FormatException) { x.Miles = 0; } // Assume Group field is 'N' x.Group = false; // Assume starttime is AM, pad with leading zero if necessary x.PurposeOfTrip = row.purpose; tl.Add(x); } mf.MileageEntries = tl; }
// GET: MileageForms/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MileageForm mileageForm = db.MileageForms.Find(id); ViewBag.Trips = db.Trips.AsNoTracking() .Where(a => a.MileageFormID == id) .OrderByDescending(a => a.Date).ToList(); var model = new MileageFormViewModel(); model.MileageForm = mileageForm; if (mileageForm == null) { return(HttpNotFound()); } return(View(model)); }
// Give a timesheetform obj, get back a partially populated timesheet obj. // TODO fix UriString, confirm vals for // marks public MileageForm PopulateMileage(PWAMileage m, MileageForm mf = null) { if (mf == null) { mf = new MileageForm(); } mf.ClientName = m.clientName.value; mf.ClientPrime = m.prime.value; mf.ProviderName = m.providerName.value; mf.ProviderId = m.providerNum.value; mf.ServiceGoal = m.serviceGoal.value; mf.ProgressNotes = m.progressNotes.value; mf.FormType = m.serviceAuthorized.value; mf.RejectionReason = ""; // mf.Submitted = DateTime.UtcNow; // mf.LockInfo = null; mf.UserActivity = ""; // mf.Edited = convUtil.wasPWAedited(m); mf.UriString = _sscontext.Stagings.Find(m.id).UriString; PopulateMileageEntries(m, mf); return(mf); }
private void FormStatusDropDown(MileageForm mileageForm = null) { ViewBag.FormStatusID = FormStatusSelectList(mileageForm?.FormStatusID); }
/******************************************************************************* * /// Static Methods *******************************************************************************/ public static AbstractFormObject FromTextract(TextractDocument doc, FormType formType) { // Here we'll Determine the type of object (timesheet or mileage form) and then // return the correct type. // Grab the first page and make sure it is the front if (doc.PageCount() < 2) { throw new ArgumentException(); } AbstractFormObject form; switch (formType) { case FormType.OR526_ATTENDANT: case FormType.OR507_RELIEF: form = new TimesheetForm(); break; case FormType.OR004_MILEAGE: form = new MileageForm(); break; default: throw new ArgumentException(); } // Do a silly assignment because C# won't let me assign the variable in the foreach loop instead // and there is no default constructor Page frontpage = doc.GetPage(0); bool frontfound = false; List <Page> backpages = new List <Page>(); // Improve front page detection foreach (var page in doc.Pages) { if (!frontfound) { // Search for Service Delivered On: foreach (var line in page.GetLines()) { // Ever form has "Service Delivered On:" on the front page, so we use // this to determine if this is the front or back. frontfound = line.ToString().Contains("vice Delivered O"); if (frontfound) { break; } } if (frontfound) { frontpage = page; } else { backpages.Add(page); } } else { backpages.Add(page); } } if (!frontfound) { throw new ArgumentException(); } var formitems = frontpage.GetFormItems(); // Top Form Information form.clientName = formitems[0].Value.ToString().Trim(); // Customer Name form.prime = formitems[1].Value.ToString().Trim(); // Prime form.providerName = formitems[2].Value.ToString().Trim(); // Provider Name form.providerNum = formitems[3].Value.ToString().Trim(); // Provider Num form.brokerage = formitems[4].Value.ToString().Trim(); // CM Organization form.scpaName = formitems[5].Value.ToString().Trim(); // SC/PA Name form.serviceAuthorized = formitems[6].Value.ToString().Trim(); // Service // Table var tables = frontpage.GetTables(); if (tables.Count == 0) { Console.WriteLine("No Table Information"); return(form); } form.AddTables(tables); // Populate back form objects form.AddBackForm(backpages[0]); return(form); }