public ActionResult Edit(int?id, HttpPostedFileBase file, missionexpenses missionex) { missionexpenses missionexpenses = ExpS.GetById((int)id); if (file != null) { string fileName = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Uploads"), fileName); file.SaveAs(path); } if (missionex.kilomtrage == null) { missionexpenses.kilomtrage = 0; } missionexpenses.cost = missionex.cost; missionexpenses.description = missionex.description; missionexpenses.kilomtrage = missionex.kilomtrage; missionexpenses.type = missionex.type; missionexpenses.image = file.FileName; missionexpenses.date = System.DateTime.Now; //context.missionexpenses.Add(post); //context.SaveChanges(); ExpS.Update(missionexpenses); ExpS.Commit(); return(RedirectToAction("Index")); }
public ActionResult Create(missionexpenses post, HttpPostedFileBase file, int?id) { if (file != null) { string fileName = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Uploads"), fileName); file.SaveAs(path); } if (post.kilomtrage == null) { post.kilomtrage = 0; } int sid = (int)Session["userId"]; System.Diagnostics.Debug.WriteLine("response :" + sid); post.user_userId = sid; // post.isApproved = 0; post.mission_refrence = id; post.image = file.FileName; post.date = System.DateTime.Now; // SendConfirmationMail(post.refrence); //context.missionexpenses.Add(post); //context.SaveChanges(); ExpS.Add(post); ExpS.Commit(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { missionexpenses missionexpenses = db.missionexpenses.Find(id); db.missionexpenses.Remove(missionexpenses); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, FormCollection collection) { missionexpenses p = ExpS.GetById(id); ExpS.Delete(p); ExpS.Commit(); //postService.Dispose(); return(RedirectToAction("Index")); }
public ActionResult Like(int?id) { missionexpenses missionexpenses = ExpS.GetById((int)id); // missionexpenses update = db.missionexpenses.ToList().Find(u => u.refrence == id); missionexpenses.isApproved += 1; //db.SaveChanges(); ExpS.Update(missionexpenses); ExpS.Commit(); return(RedirectToAction("Index")); }
// GET: Expances/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } missionexpenses missionexpenses = ExpS.GetById((int)id); if (missionexpenses == null) { return(HttpNotFound()); } return(View(missionexpenses)); }
// GET: missionexpenses/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } missionexpenses missionexpenses = db.missionexpenses.Find(id); if (missionexpenses == null) { return(HttpNotFound()); } return(View(missionexpenses)); }
// GET: missionexpenses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } missionexpenses missionexpenses = db.missionexpenses.Find(id); if (missionexpenses == null) { return(HttpNotFound()); } ViewBag.mission_refrence = new SelectList(db.mission, "refrence", "description", missionexpenses.mission_refrence); ViewBag.user_userId = new SelectList(db.user, "userId", "email", missionexpenses.user_userId); return(View(missionexpenses)); }
// GET: Expances/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } missionexpenses missionexpenses = ExpS.GetById((int)id); if (missionexpenses == null) { return(HttpNotFound()); } SendConfirmationMail((int)id); return(View(missionexpenses)); }
public ActionResult Dislike(int?id) { missionexpenses missionexpenses = ExpS.GetById((int)id); // missionexpenses update = db.missionexpenses.ToList().Find(u => u.refrence == id); if (missionexpenses.isApproved == 0) { missionexpenses.isApproved += 1; ExpS.Update(missionexpenses); ExpS.Commit(); } else { missionexpenses.isApproved -= 1; ExpS.Update(missionexpenses); ExpS.Commit(); } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "refrence,isApproved,totalRecovered,mission_refrence,cost,date,description,image,kilomtrage,totalCost,type,user_userId")] missionexpenses missionexpenses, HttpPostedFileBase file) { if (file != null) { string fileName = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Uploads"), fileName); file.SaveAs(path); } missionexpenses.image = file.FileName; missionexpenses.date = System.DateTime.Now; // if (ModelState.IsValid) //{ db.Entry(missionexpenses).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Expances")); // } //ViewBag.mission_refrence = new SelectList(db.mission, "refrence", "description", missionexpenses.mission_refrence); //ViewBag.user_userId = new SelectList(db.user, "userId", "email", missionexpenses.user_userId); //return View(missionexpenses); }
public ActionResult Create(missionexpenses post, HttpPostedFileBase file, int?id) { if (file != null) { string fileName = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Uploads"), fileName); file.SaveAs(path); } using (var engine = new TesseractEngine(Server.MapPath(@"~/tessdata"), "fra", EngineMode.Default)) { using (var image = new System.Drawing.Bitmap(file.InputStream)) { using (var pix = PixConverter.ToPix(image)) { using (var page = engine.Process(pix)) { if (post.description == null) { System.Diagnostics.Debug.WriteLine(page.GetText()); if (Regex.IsMatch(page.GetText(), "Restaurant")) { post.type = "Restaurant"; } else if (Regex.IsMatch(page.GetText(), "Hotel")) { post.type = "Hotel"; } else if (Regex.IsMatch(page.GetText(), "Bus")) { post.type = "Transport"; } else if (Regex.IsMatch(page.GetText(), "Plain")) { post.type = "Transport"; } else if (Regex.IsMatch(page.GetText(), "Taxi")) { post.type = "Transport"; } else { post.type = "Other"; } string result = Regex.Match(page.GetText(), @"(?<=TOTAL )\-?\d+(?:\.\d+)?").Value; string REGEX = Regex.Match(page.GetText(), @"([\w]+\s+){" + 3 + "}").Value; string lama = Regex.Match(page.GetText(), @"(?<=Remise )\-?\d+(?:\.\d+)?").Value; string tama = Regex.Match(page.GetText(), @"(?<=Discount )\-?\d+(?:\.\d+)?").Value; string tax = Regex.Match(page.GetText(), @"(?<=Tax )\-?\d+(?:\.\d+)?").Value; System.Diagnostics.Debug.WriteLine(result); System.Diagnostics.Debug.WriteLine(lama); post.cost = Convert.ToDouble(result.Replace(".", ",")); if (tax == null) { post.description = REGEX + "a Discount of :" + lama + tama; } else { post.description = REGEX + " a Discount of :" + lama + tama + " and a tax of :" + tax; } } } } } } if (post.kilomtrage == null) { post.kilomtrage = 0; } int sid = (int)Session["userId"]; System.Diagnostics.Debug.WriteLine("response :" + sid); post.user_userId = sid; // post.isApproved = 0; post.mission_refrence = id; post.image = file.FileName; post.date = System.DateTime.Now; // SendConfirmationMail(post.refrence); //context.missionexpenses.Add(post); //context.SaveChanges(); ExpS.Add(post); try { ExpS.Commit(); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { System.Diagnostics.Debug.WriteLine("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } return(RedirectToAction("Index")); }