コード例 #1
0
        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 });
        }
コード例 #2
0
        public ActionResult AddBuilding(int? ClientID)
        {
           
            var building = new BuildingInfoVM();
            building.StatesList =db.States.Select(c=> new State{myState =c.State, value=c.State }).ToList();
            if (ClientID != null)
            {
                ViewBag.ClientID = ClientID;
                building.ClientID = (int)ClientID;
            }

            return View(building);
        }