public ActionResult SurveyorRes(string Option) { // Let's get all states that we need for a DropDownList Status_surveyor ss = new Status_surveyor(); int aa = (int)Session["CustId"]; ss.SurvId = aa; int s; string Text = ""; if (Option == "true") { s = 1; Text = "You Are Available"; } else { s = 0; Text = "You Are Not Available"; } ss.Status = s; InsureEntities ii = new InsureEntities(); var a = ii.Status_surveyor.Where(m => m.SurvId == aa).FirstOrDefault(); ss.ID = a.ID; if (a != null) { ii.Entry(a).State = EntityState.Detached; ii.Entry(ss).State = EntityState.Modified; ii.SaveChanges(); } return(Json("" + Text, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteGarrage(int id) { InsureEntities db = new InsureEntities(); var jsondata = db.GarrageMasters.Where(q => q.Id == id).FirstOrDefault(); if (jsondata != null) { db.GarrageMasters.Remove(jsondata); db.SaveChanges(); } return(View(jsondata)); }
public ActionResult UploadReport(FormCollection fc, HttpPostedFileBase file) { InsureEntities db = new InsureEntities(); ReportMst rm = new ReportMst(); var id = Convert.ToInt32(fc[0]); rm.AccidentId = id; rm.ReportType = fc[1]; var sid = db.AccidentInfoes.Where(m => m.AccidentId == id).Select(m => m.SurveyorId).FirstOrDefault(); var name = db.Registrations.Where(m => m.UserID == sid).Select(m => m.EmailId).FirstOrDefault(); rm.SurveyorId = sid; string h = ""; // E:\project_shown\checkintegration\checkintegration\Content\FilePath\ try { if (file != null) { string path = Path.Combine(Server.MapPath("~/Content/FilePath/"), Path.GetFileName(file.FileName)); string n = Path.GetFileName(file.FileName); file.SaveAs(path); rm.FilePath = "~/Content/FilePath/" + n; db.ReportMsts.Add(rm); db.SaveChanges(); //return Json(new { data = "fdsdsass" +h}, JsonRequestBehavior.AllowGet); return(RedirectToAction("View_Accident", "Admin")); } return(Json(new { data = "Faillll" + h }, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { string ms = ""; foreach (var eve in e.EntityValidationErrors) { ms += "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + eve.Entry.Entity.GetType().Name + eve.Entry.State; foreach (var ve in eve.ValidationErrors) { ms += "- Property: \"{0}\", Error: \"{1}\"" + ve.PropertyName + ve.ErrorMessage; } } return(Json(new { success = false, message = ms }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteServeyor(int id) { //if( Session["UserId"] == null) //{ // return RedirectToAction("Login","Home"); //} InsureEntities db = new InsureEntities(); var jsondata = db.Registrations.Where(q => q.UserID == id).FirstOrDefault(); if (jsondata != null) { db.Registrations.Remove(jsondata); db.SaveChanges(); } return(View(jsondata)); }
public ActionResult AddorEditGarrage(GarrageMaster rm) { try { InsureEntities db = new InsureEntities(); var data = db.GarrageMasters.Where(m => m.Id == rm.Id).FirstOrDefault(); if (data != null) { //rm.Id = data.Id; rm.Name = data.Name; rm.Address = data.Address; rm.PhoneNo = data.PhoneNo; rm.OwnerName = data.OwnerName; rm.Description = data.Description; rm.IsAuth = data.IsAuth; rm.CreatedBy = data.CreatedBy; db.Entry(data).State = EntityState.Detached; db.Entry(rm).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Updation Error" }, JsonRequestBehavior.AllowGet)); } } catch (DbEntityValidationException e) { string ms = ""; foreach (var eve in e.EntityValidationErrors) { ms += "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + eve.Entry.Entity.GetType().Name + eve.Entry.State; foreach (var ve in eve.ValidationErrors) { ms += "- Property: \"{0}\", Error: \"{1}\"" + ve.PropertyName + ve.ErrorMessage; } } return(Json(new { success = false, message = ms }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddorEditSurveyor(Registration rm) { try { InsureEntities db = new InsureEntities(); var data = db.Registrations.Where(m => m.UserID == rm.UserID).FirstOrDefault(); if (data != null) { rm.UserName = data.UserName; rm.ConfirmPassword = data.ConfirmPassword; rm.Gender = data.Gender; rm.NewConfirmPassword = data.NewConfirmPassword; rm.Password = data.Password; rm.Pincode = data.Pincode; rm.RoleId = data.RoleId; rm.Address = data.Address; db.Entry(data).State = EntityState.Detached; db.Entry(rm).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Updation Error" }, JsonRequestBehavior.AllowGet)); } } catch (DbEntityValidationException e) { string ms = ""; foreach (var eve in e.EntityValidationErrors) { ms += "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + eve.Entry.Entity.GetType().Name + eve.Entry.State; foreach (var ve in eve.ValidationErrors) { ms += "- Property: \"{0}\", Error: \"{1}\"" + ve.PropertyName + ve.ErrorMessage; } } return(Json(new { success = false, message = ms }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddGarrage(Models.GarrageMaster gm) { try { if (ModelState.IsValid) { using (InsureEntities db = new InsureEntities()) { db.GarrageMasters.Add(gm); db.SaveChanges(); ModelState.Clear(); ViewBag.Error = "Sucessfully Submitted"; gm = null; return(RedirectToAction("Dashboard", "Admin")); } } else { ModelState.AddModelError("", "Data is not correct"); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } //throw; } return(View()); }
public ActionResult AddServeyor(Models.Registration user) { try { if (ModelState.IsValid) { user.RoleId = 3; Status_surveyor ss = new Status_surveyor(); using (InsureEntities db = new InsureEntities()) { if (user.UserID == 0) { var username = db.Registrations.Where(u => u.UserName == user.UserName).FirstOrDefault(); var em = db.Registrations.Where(u => u.EmailId == user.EmailId).FirstOrDefault(); if (username != null) { ViewBag.Error = "UserName already Exist"; return(View("AddServeyor", user)); } else if (em != null) { ViewBag.Error = "EmailId already Exist"; return(View("AddServeyor", user)); } else { db.Registrations.Add(user); db.SaveChanges(); ss.SurvId = user.UserID; ss.Status = 1; db.Status_surveyor.Add(ss); db.SaveChanges(); ModelState.Clear(); ViewBag.Error = "Sucessfully Submitted"; user = null; return(RedirectToAction("Dashboard", "Admin")); } } else { var username = db.Registrations.Where(u => u.UserName == user.UserName && u.UserID != user.UserID).FirstOrDefault(); var em = db.Registrations.Where(u => u.EmailId == user.EmailId && u.UserID != user.UserID).FirstOrDefault(); if (username != null) { ViewBag.Error = "UserName already Exist"; return(View("AddServeyor", user)); } else if (em != null) { ViewBag.Error = "EmailId already Exist"; return(View("AddServeyor", user)); } else { db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ModelState.Clear(); ViewBag.Error = "Sucessfully Submitted"; user = null; return(RedirectToAction("Dashboard", "Admin")); } } } } else { ModelState.AddModelError("", "Data is not correct"); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(View()); }
public ActionResult Accident_Register(Models.AccidentInfo ss) { try { // Registration rg=new Registration(); ss.CustId = (int)Session["UserId"]; InsureEntities db1 = new InsureEntities(); var a = db1.Status_surveyor.Where(m => m.Status == 1).Select(m => m.SurvId).ToArray(); var rand = new Random(); var sid = a[rand.Next(a.Length)]; ss.SurveyorId = sid; ss.Status = 0; if (ModelState.IsValid) { using (InsureEntities db = new InsureEntities()) { db.AccidentInfoes.Add(ss); db.SaveChanges(); ModelState.Clear(); //Session["UserID"] = user.UserID; ViewBag.Error = "Sucessfully Submitted"; ss = null; return(RedirectToAction("Homepage", "Home")); } } else { /* using (InsureEntities2 db = new InsureEntities2()) * { * * db.FeedbackMasters.Add(fm); * db.SaveChanges(); * ModelState.Clear(); * //Session["UserID"] = user.UserID; * ViewBag.Error = "Sucessfully Submitted"; * fm = null; * return RedirectToAction("Login", "Home"); * * * } */ // ModelState.AddModelError("", "Data is not correct"); return(RedirectToAction("Register", "Home")); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(View()); // throw; } /* catch(Exception e) * { * Console.Write(e); * return View(); * * }*/ }
public ActionResult ContactUs(Models.FeedbackMaster fm) { try { fm.Date = DateTime.Now; fm.CustId = (System.Int32)Session["UserId"]; if (ModelState.IsValid) { using (InsureEntities db = new InsureEntities()) { /* var newUser = db.FeedbackMasters.Create(); * newUser.CustId = fm.UserId; * // newUser.Date = fm.Date; * newUser.feedback = fm.feedback;*/ db.FeedbackMasters.Add(fm); db.SaveChanges(); ModelState.Clear(); //Session["UserID"] = user.UserID; ViewBag.Error = "Sucessfully Submitted"; fm = null; return(RedirectToAction("Login", "Home")); } } else { /* using (InsureEntities2 db = new InsureEntities2()) * { * * db.FeedbackMasters.Add(fm); * db.SaveChanges(); * ModelState.Clear(); * //Session["UserID"] = user.UserID; * ViewBag.Error = "Sucessfully Submitted"; * fm = null; * return RedirectToAction("Login", "Home"); * * * } */ // ModelState.AddModelError("", "Data is not correct"); return(RedirectToAction("Register", "Home")); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(View()); // throw; } catch (Exception e) { Console.Write(e); return(View()); } }
// string OldPassword, string NewPassword, string NewConfirmPassword,string UserID public ActionResult Change_Password(Models.Registration user) { InsureEntities db = new InsureEntities(); //LoginMst obj = new LoginMst(); var lst = db.Registrations.Where(P => P.EmailId == user.EmailId && P.Password == user.Password).SingleOrDefault(); var ls = db.Registrations.Where(P => P.Password == user.NewPassword).SingleOrDefault(); //bool IsUserExist = db.LoginMsts.Where(P => P.SrNo == UserID && P.Password==OldPassword).Any(); if (lst != null) { ViewBag.message = "Changing done"; if (ls != null) { ViewBag.Error = "New Password already Exist"; return(RedirectToAction("Change_Password", "Home")); } else { var ab = db.Registrations.Where(P => P.EmailId == user.EmailId && P.Password == user.Password).SingleOrDefault(); // var cd = db.Registrations.Where(P => P.Password == user.NewPassword).SingleOrDefault(); Registration rg = new Registration(); rg.UserID = ab.UserID; rg.FirstName = ab.FirstName; rg.LastName = ab.LastName; rg.UserName = ab.UserName; rg.EmailId = ab.EmailId; rg.Password = user.NewPassword; rg.ConfirmPassword = user.NewConfirmPassword; rg.Gender = ab.Gender; rg.RoleId = ab.RoleId; rg.Address = ab.Address; rg.Pincode = ab.Pincode; rg.PhoneNumber = ab.PhoneNumber; db.Entry(ab).State = EntityState.Detached; db.Entry(rg).State = EntityState.Modified; /* lst.Password = user.NewPassword; * lst.ConfirmPassword = user.NewConfirmPassword;*/ ViewBag.message = "Changing password successflly done"; // db.Registrations.Add(user); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } /* System.Diagnostics.Debug.Write("Hello via Debug!"+lst.Password); * return RedirectToAction("Change_Password", "Home");*/ return(Json(ViewBag.message)); } //return 0; } else { ViewBag.Error = "Email Id or Password is wrong!!"; return(RedirectToAction("Change_Password", "Home"));; } /*catch (DbEntityValidationException ex) * { * foreach (var entityValidationErrors in ex.EntityValidationErrors) * { * foreach (var validationError in entityValidationErrors.ValidationErrors) * { * Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); * } * } * }*/ return(View()); }
public ActionResult Register(Models.Registration user, FormCollection fc) { try { if (ModelState.IsValid) { user.RoleId = 2; using (InsureEntities db = new InsureEntities()) { /* var newUser = db.Registrations.Create(); * // newUser.UserID = user.UserID; * newUser.FirstName = user.FirstName; * newUser.LastName = user.LastName; * newUser.UserName = user.UserName; * newUser.EmailId = user.EmailId; * newUser.Password = user.Password; * newUser.ConfirmPassword = user.ConfirmPassword; * newUser.Gender = user.Gender; * // newUser.RoleId = user.RoleId; * newUser.Address = user.Address; * newUser.Pincode = user.Pincode; * newUser.PhoneNumber = user.PhoneNumber; */ var username = db.Registrations.Where(u => u.UserName == user.UserName).FirstOrDefault(); var em = db.Registrations.Where(u => u.EmailId == user.EmailId).FirstOrDefault(); if (username != null) { ViewBag.Error = "UserName already Exist"; return(View("Register", user)); } else if (em != null) { ViewBag.Error = "EmailId already Exist"; return(View("Register", user)); } else { //user.FirstName user.Gender = fc["type"].ToString(); db.Registrations.Add(user); db.SaveChanges(); ModelState.Clear(); Session["UserID"] = user.UserID; ViewBag.Error = "Sucessfully Submitted"; user = null; return(RedirectToAction("Index", "Home")); } } } else { ModelState.AddModelError("", "Data is not correct"); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(View()); }