public ActionResult ClientIndex()
        {
            //this is for the add client partial view
            ViewBag.ClientModel = new ClientsVM();
            
        
        var ObjClients = new ClientsVM();
        ObjClients.ListOfClients = db.Clients
               .Select(c => new ClientsVM
               {
                   ID = c.ID,
                   ClientName = c.ClientName,
                   BuildingCount = (int)c.BuildingCount,
                   Address = c.Address,
                    Phone =c.Phone,
                     city=c.City,
                      State = c.State,
                      zipcode = c.ZipCode,
                       Fax = c.Fax,
                       Email = c.Email
                    
                  
               }).Take(10).ToList();

        ObjClients.States = db.States.Select(c => new State { value = c.State, myState = c.State }).ToList();

        foreach (var item in ObjClients.ListOfClients)
            {
                if (item.BuildingCount <=0)
                {
                    item.BuildingCount = 0;
                }
            };
        return View(ObjClients);
        }
        public ActionResult AddClient(ClientsVM model, int? buildingcount, int? ContactID)
        {




            try 
            {

                if (ModelState.IsValid)
                {

                    if (buildingcount == null)
                    {
                        //TO DO: this needs to be handle on while adding buildin. 
                        // cound should increase when adding building and decrease when deleting building
                        buildingcount = 0;
                    }
                    var newclient = new Clients
                    {
                        ClientName = model.ClientName,
                        BuildingCount = (int)buildingcount,
                        Address = model.Address,
                        City = model.city,
                        State = model.State,
                        ZipCode = model.zipcode,
                        Fax = model.Fax,
                        Phone = model.Phone,
                        Email = model.Email
                    };

                    db.Clients.Add(newclient);
                    db.SaveChanges();
                }
                else
                {
                    return RedirectToAction("clientIndex");
                    
                }
         } 
            catch(Exception e)
            {
                ViewBag.ErrorMessage = e.Message;
                return null;
            }

            return RedirectToAction("ClientIndex");
        }