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));
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
 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));
     }
 }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        // 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());
        }