public JsonResult UpdateContractor(NewContractor model)
        {
            Contractor objC = new Contractor
            {
                Id = model.ASPNETUSERID,
                CompanyName = model.CName,
                Address = model.CAddress,
                City = model.CCity,
                State = model.CState,
                Zipcode = model.CZipcode,
                Phone = model.CMainPhone,
                ContactName = model.PName,
                ContractPhone = model.PPhone,
                Comments = model.Comments,
                Email = model.Email,
                SendNewPass = model.SendNewPassword,
                CategoryName = model.CatName,
                BuildingID = model.BuildingID
            };

            db.Contractor.Attach(objC);
            var Entry = db.Entry(objC);
            Entry.Property(c => c.CategoryName).IsModified = true;
            Entry.Property(c => c.Address).IsModified = true;
            Entry.Property(c => c.State).IsModified = true;
            Entry.Property(c => c.Zipcode).IsModified = true;
            Entry.Property(c => c.Phone).IsModified = true;
            Entry.Property(c => c.ContactName).IsModified = true;
            Entry.Property(c => c.ContractPhone).IsModified = true;
            Entry.Property(c => c.Email).IsModified = true;
            Entry.Property(c => c.CategoryName).IsModified = true;

            db.SaveChanges();
          

            var objList = db.Contractor.Where(c => c.BuildingID == model.BuildingID).Select(c => new
            {
                ID = c.Id,
                CompanyName = c.CompanyName,
                Address = c.Address,
                City = c.City,
                State = c.State,
                Zipcode = c.Zipcode,
                Phone = c.Phone,
                ContactName = c.ContactName,
                ContactPhone = c.ContractPhone,
                Comments = c.Comments,
                Email = c.Email,
                SendNewPassword = c.SendNewPass,
                Category = c.CategoryName,
                BuildingID = c.BuildingID
            }).ToList();
            var JSONdATA = Json(objList);
            return new JsonResult { Data = JSONdATA, JsonRequestBehavior = JsonRequestBehavior.AllowGet };          
        }
        public JsonResult InsertNewContractor(NewContractor model)
        {
            //1)creat aspnetuserID
            string password = PasswordGenerator.GeneratePassword("8").ToString();
            //2) insert user
            var UserID = RegisterUsers.InsertUser(model.Email, model.CMainPhone, password);
            //3) insert User Role Contractor
            var result = RegisterUsers.InserToRole("Contractor", UserID);
            //4) add Contractor
            //Transfer
            Contractor objC = new Contractor
            {
                 Id = UserID,
                 CompanyName = model.CName,
                 Address = model.CAddress,
                 City = model.CCity,
                 State = model.CState,
                 Zipcode = model.CZipcode,
                 Phone = model.CMainPhone,
                 ContactName = model.PName,
                 ContractPhone = model.PPhone,
                 Comments = model.Comments,
                 Email = model.Email,
                 SendNewPass = model.SendNewPassword,
                 CategoryName = model.CatName,
                 BuildingID = model.BuildingID                   
            };

            db.Contractor.Add(objC);
            db.SaveChanges();

            var objList = db.Contractor.Where(c=>c.BuildingID == objC.BuildingID).Select(c => new {
                      ID = c.Id,
                      CompanyName = c.CompanyName,
                      Address = c.Address,
                      City = c.City,
                      State = c.State,
                      Zipcode = c.Zipcode,
                      Phone = c.Phone,
                      ContactName = c.ContactName,
                      ContactPhone = c.ContractPhone,
                      Comments = c.Comments,
                      Email = c.Email,
                      SendNewPassword = c.SendNewPass,
                      Category = c.CategoryName,
                      BuildingID = c.BuildingID
            }).ToList();
            var JSONdATA = Json(objList);
            return new JsonResult { Data = JSONdATA, JsonRequestBehavior = JsonRequestBehavior.AllowGet };          
        }