public ActionResult Create(Ls.Prj.Entity.House house) { // public ActionResult Create([Bind(Include = "Id,nickname,state,city,address,housePhoto,zillowLink,purchasePrice,sqFeet,sqFeetPrice,constructionYear,grossRent,percVacancy,extimateAccountingExpense,extimateCondoExpense,extimateInsuranceExpense,extimateMaintenanceExpense,extimateProperyManagerExpense,extimateUtilitiesExpense,extimatePestControlExpense,extimatePropertyTax,closingCosts,titleCompanyCosts,agencyCosts,otherClosingCosts,enabled")] Ls.Prj.Entity.House house) //{ var vm = InitializeIndexView(); UsaHousesPageManager ObjUsaHousesPageManager = new UsaHousesPageManager(); Ls.Prj.Entity.House ObjHouse = null; Ls.Prj.Entity.House HouseObj = SetDefaultForHouseEntity(house); if (ModelState.IsValid) { ObjHouse = ObjUsaHousesPageManager.NewUsaHouse(HouseObj); //db.House.Add(HouseObj); //db.SaveChanges(); return(RedirectToAction("Index")); } //Ls.Prj.Entity.House Casa = ObjUsaHousesPageManager.GetUsaHouse(ObjHouse.id); // House Casa = db.House.Find(house.Id); vm.House = house; //vm.House = new UsaHouseDTO(); return(View(vm)); }
public ActionResult Edit(Ls.Prj.Entity.House house) { // public ActionResult Edit([Bind(Include = "Id,nickname,state,city,street,housePhoto,zillowLink,purchasePrice,sqFeet,sqFeetPrice,constructionYear,grossRent,percVacancy,extimateAccountingExpense,extimateCondoExpense,extimateInsuranceExpense,extimateMaintenanceExpense,extimateProperyManagerExpense,extimateUtilitiesExpense,extimatePestControlExpense,extimatePropertyTax,closingCosts,titleCompanyCosts,agencyCosts,otherClosingCosts,enabled")] House house) //{ if (ModelState.IsValid) { UsaHousesPageManager ObjUsaHousesPageManager = new UsaHousesPageManager(); ObjUsaHousesPageManager.UpdateUsaHouse(house); //db.Entry(house).State = EntityState.Modified; //db.SaveChanges(); return(RedirectToAction("Index")); } return(View(house)); }
private Ls.Prj.Entity.House SetDefaultForHouseEntity(Ls.Prj.Entity.House HouseObj) { Type type = HouseObj.GetType(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo property in properties) { if (property.PropertyType == typeof(decimal?)) { // if (property.GetType()== typeof(decimal?)) //{ if (property.GetValue(HouseObj, null) == null) { property.SetValue(HouseObj, (decimal)1, null); } } else if (property.PropertyType == typeof(int?)) { // if (property.GetType()== typeof(decimal?)) //{ if (property.GetValue(HouseObj, null) == null) { property.SetValue(HouseObj, 1, null); } } else if (property.PropertyType == typeof(bool?)) { // if (property.GetType()== typeof(decimal?)) //{ if (property.GetValue(HouseObj, null) == null) { property.SetValue(HouseObj, true, null); } } Console.WriteLine("Name: " + property.Name + ", Value: " + property.GetValue(HouseObj, null)); } if (HouseObj.agencyCosts == null) { HouseObj.agencyCosts = 0; } return(HouseObj); }
// GET: Houses/Edit/5 public ActionResult Edit(int?id) { var vm = InitializeIndexView(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UsaHousesPageManager UsaHousesPageManagerObj = new UsaHousesPageManager(); Ls.Prj.Entity.House house = UsaHousesPageManagerObj.GetUsaHouse((int)id); //TODO:Da togliere!!! house = SetDefaultForHouseEntity(house); //House house = db.House.Find(id); if (house == null) { return(HttpNotFound()); } vm.House = house; //vm.House = new Ls.Prj.Entity.House(); return(View(vm)); //return View(house); }