public async Task<ActionResult> BuildingDelete(Buildings model, int BuildingID, int? ClientID)
        {
            if (ModelState.IsValid)
            {
                var mynewbuilding = new Buildings
                {
                     BuildingName = model.BuildingName,
                      Address = model.Address,
                       City =model.City,
                     State = model.City,
                     Zipcode = model.Zipcode,
                     ClientID = ClientID,
                     BuildingPhone = model.BuildingPhone,
                     NumberOfApartment = model.NumberOfApartment,
                     ID = model.ID


                };


                var Entry = db.Entry(mynewbuilding);
                if (Entry.State == EntityState.Detached) 
                { 
                    db.Buildings.Attach(mynewbuilding);
                }
               
                db.Buildings.Remove(mynewbuilding);
                await db.SaveChangesAsync();
            }

            return RedirectToAction("BuildingIndex", new { ClientID = ClientID });
        }
        public async Task<ActionResult> BuildingEdit(Buildings model, int id)
        {
            if (ModelState.IsValid)
            {
                db.Buildings.Attach(model);
                var Entry = db.Entry(model);
                Entry.Property(c => c.BuildingName).IsModified = true;
                Entry.Property(c => c.Address).IsModified = true;
                Entry.Property(c => c.City).IsModified = true;
                Entry.Property(c => c.State).IsModified = true;
                Entry.Property(c => c.Manager).IsModified = true;
                Entry.Property(c => c.Zipcode).IsModified = true;
                Entry.Property(c => c.BuildingPhone).IsModified = true;
                await db.SaveChangesAsync();
            
            }

            return RedirectToAction("buildingIndex", new {ClientID = model.ClientID });
        
        }
        public async Task<ActionResult> AddBuilding(BuildingInfoVM apartmentvm)
        {if (ModelState.IsValid)
            {
                //if (User.Identity.IsAuthenticated)
                //{
            if(ModelState.IsValid)
            {
                    var apartment = new Buildings
                    {
                        BuildingName = apartmentvm.BuildingName,
                        Address = apartmentvm.Address,
                        BuildingPhone = apartmentvm.BuildingPhone,
                        NumberOfApartment = apartmentvm.NumberOfApart,
                        City = apartmentvm.City,
                        State = apartmentvm.States,
                        Zipcode = apartmentvm.ZipCode,
                        Manager = apartmentvm.Manager,
                        ClientID = apartmentvm.ClientID
                    };
                    db.Buildings.Add(apartment);
                    await db.SaveChangesAsync();
                   
                    }  
                //}
            //TODO Exception 
            }



        return RedirectToAction("BuildingIndex", new { ClientID = apartmentvm.ClientID });
        }