public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,Phone,Email")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "LocationID,StreetName,StreetNumber,City,State,ZipCode,HouseID")] Location location) { if (ModelState.IsValid) { db.Locations.Add(location); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LocationID = new SelectList(db.Houses, "Location_HouseID", "Rooms", location.LocationID); ViewBag.LocationID = new SelectList(db.Houses, "Location_HouseID", "Rooms", location.LocationID); return(View(location)); }
public ActionResult Create([Bind(Include = "TypeID,Style,HouseID")] Type type) { if (ModelState.IsValid) { db.Types.Add(type); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TypeID = new SelectList(db.Houses, "Location_HouseID", "Rooms", type.TypeID); ViewBag.TypeID = new SelectList(db.Houses, "Location_HouseID", "Rooms", type.TypeID); return(View(type)); }
public ActionResult Create([Bind(Include = "Location_HouseID,Rooms,Floors,BuildDate,IsGarage,CustomerID")] House house) { if (ModelState.IsValid) { db.Houses.Add(house); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", house.CustomerID); ViewBag.Location_HouseID = new SelectList(db.Locations, "LocationID", "StreetName", house.Location_HouseID); ViewBag.Location_HouseID = new SelectList(db.Types, "TypeID", "Style", house.Location_HouseID); ViewBag.Location_HouseID = new SelectList(db.Locations, "LocationID", "StreetName", house.Location_HouseID); ViewBag.Location_HouseID = new SelectList(db.Types, "TypeID", "Style", house.Location_HouseID); return(View(house)); }
public ActionResult Register(Accounts acc) { if (ModelState.IsValid) { var db = new ConstructionEntities(); var row = new Users(); row.Username = acc.Username; row.Password = acc.Password; row.ConfirmPass = acc.ConfirmPass; row.FirstName = acc.FirstName; row.LastName = acc.LastName; row.Email = acc.Email; row.Phone = acc.Phone; //row.Admin = false; db.Users.Add(row); var rowsCount = db.SaveChanges(); ModelState.Clear(); Session["userId"] = row.Id.ToString(); Session["user"] = row.Username.ToString(); return(RedirectToAction("Welcome", "Home")); //ViewBag.Message = acc.Username + " has been successfully registered"; // return Redirect("/home/index"); } return(View(acc)); }
public void Context() { _newGrp = new UnitRenoGrp { hProp = 23, RenoGrpName = "when_deleting_existing", RenoGrpDesc = "Test description", LeadContractor = "Test Lead Contractor" }; _entities = new ConstructionEntities(); _target = new UnitRenovationGroupRepository(_entities); Func<UnitRenoGrp, bool> existingEntityExpression = (existingGrp => existingGrp.RenoGrpName == _newGrp.RenoGrpName && existingGrp.hProp == _newGrp.hProp && existingGrp.RenoGrpDesc == _newGrp.RenoGrpDesc && existingGrp.LeadContractor == _newGrp.LeadContractor); //remove existing data context var existing = _entities.UnitRenoGrps.Where(existingEntityExpression).ToList(); if (existing.Any()) { existing.ForEach(rg => { _entities.UnitRenoGrps.Attach(rg); _entities.UnitRenoGrps.Remove(rg); }); _entities.SaveChanges(); } //create a new entity to delete _entities.UnitRenoGrps.Add(_newGrp); _entities.SaveChanges(); var saveTarget = _entities.UnitRenoGrps.Where(existingEntityExpression).ToList()[0]; saveTarget.ArchiveFlag = true; //delete the entity _target.Delete(existingEntityExpression); _result = _entities.UnitRenoGrps.Where(existingEntityExpression).ToList()[0]; }
public ActionResult Reference(References rf) { var DbContext = new ConstructionEntities(); var row = new Reference(); row.Reference1 = rf.Reference; row.Referee = rf.Referee; DbContext.Reference.Add(row); var rowsCount = DbContext.SaveChanges(); return(RedirectToAction("Reference", "Reference")); }
public ActionResult ConstructionBuilder(ConWork vm) { var DbContext = new ConstructionEntities(); var row = new ConstructionPrice(); decimal DemCostPrice = 50; decimal SiteClearCost = 50; vm.PreConTotal = (vm.DemMetre * DemCostPrice) + (vm.SiteClearMetre * SiteClearCost); decimal SubStruc = 120; vm.StructureCost = (vm.FloorLength * SubStruc) * vm.Stories; decimal BuildSize = vm.FloorLength * vm.Stories; decimal Walls; //int Roof = 100; if (vm.ExternalWall == "brick") { Walls = 450 * BuildSize; } else if (vm.ExternalWall == "stone") { Walls = 500 * BuildSize; } else if (vm.ExternalWall == "wood") { Walls = 325 * BuildSize; } else { Walls = 0; } vm.SuperStructCost = Walls; //+ (Roof + vm.RoofStructure); decimal door = 400; decimal window = 600; decimal Rooftiles; if (vm.RoofTiles == "crt") { Rooftiles = 500 * vm.FloorLength; } else if (vm.RoofTiles == "nsrt") { Rooftiles = 700 * vm.FloorLength; } else if (vm.RoofTiles == "crt2") { Rooftiles = 550 * vm.FloorLength; } else if (vm.RoofTiles == "asrt") { Rooftiles = 400 * vm.FloorLength; } else { Rooftiles = 0; } vm.ExternalCost = (door * vm.NoDoors) + (window * vm.NoWindows) + Rooftiles; decimal plumbingCost; decimal heatingCost; decimal electricCost; decimal plasteringCost; decimal decorCost; if (vm.Plumbing == true) { plumbingCost = 100 * BuildSize; } else { plumbingCost = 0; } if (vm.Heating == true) { heatingCost = 100 * BuildSize; } else { heatingCost = 0; } if (vm.Electrics == true) { electricCost = 100 * BuildSize; } else { electricCost = 0; } if (vm.Plastering == true) { plasteringCost = 100 * BuildSize; } else { plasteringCost = 0; } if (vm.Decor == true) { decorCost = 100 * BuildSize; } else { decorCost = 0; } decimal PatioCost = 50; decimal DriveWayCost = 50; vm.ServicesCost = plumbingCost + heatingCost + electricCost + plasteringCost + decorCost + (PatioCost * vm.PatioMetre) + (DriveWayCost * vm.DriveWayMetre); vm.Extra = 250 * BuildSize; vm.TotalCost = vm.PreConTotal + vm.StructureCost + vm.SuperStructCost + vm.ExternalCost + vm.ServicesCost + vm.Extra; row.Demolition = vm.Demolition; row.DemMetre = vm.DemMetre; row.SiteClear = vm.SiteClear; row.SiteClearMetre = vm.SiteClearMetre; row.PreConTotal = vm.PreConTotal; row.Stories = vm.Stories; row.FloorLength = vm.FloorLength; row.StructureCost = vm.StructureCost; row.ExternalWall = vm.ExternalWall; row.RoofStructure = vm.RoofStructure; row.SuperStructCost = vm.SuperStructCost; row.RoofTiles = vm.RoofTiles; row.NoDoors = vm.NoDoors; row.NoWindows = vm.NoWindows; row.ExternalCost = vm.ExternalCost; row.Plumbing = vm.Plumbing; row.Heating = vm.Heating; row.Electrics = vm.Electrics; row.Plastering = vm.Plastering; row.Decor = vm.Decor; row.Patio = vm.Patio; row.PatioMetre = vm.PatioMetre; row.DriveWay = vm.DriveWay; row.DriveWayMetre = vm.DriveWayMetre; row.ServicesCost = vm.ServicesCost; row.Extra = vm.Extra; row.TotalCost = vm.TotalCost; int UserVal = Convert.ToInt32(Session["userId"]); row.UserId = UserVal; DbContext.ConstructionPrice.Add(row); var rowsCount = DbContext.SaveChanges(); return(RedirectToAction("ConstructionBuilderSummary", "ConstructionSummary")); //return View(vm); }
public void Context() { var newRenovation = new Contexts.UnitReno { hUnitRenoGrp = 1, hUnit = 16, EstPrice = 1500 }; _unitRenovations = new List<Contexts.UnitReno> {newRenovation}; _entities = new ConstructionEntities(); //remove existing context before test run if (_entities.UnitRenoes.Any(existingRenovation => existingRenovation.hUnitRenoGrp == newRenovation.hUnitRenoGrp && existingRenovation.hUnit == newRenovation.hUnit)) { _entities.UnitRenoes.Attach(newRenovation); _entities.UnitRenoes.Remove(newRenovation); _entities.SaveChanges(); } _target = new UnitRenovationRepository(_entities); _target.Save(_unitRenovations); _results = _target.Retrieve((r => r.EstPrice == newRenovation.EstPrice)).ToList(); }
public void Context() { var newGrp = new UnitRenoGrp { hProp = 1, RenoGrpName = "when_saving_new", RenoGrpDesc = "Test description", LeadContractor = "Test Lead Contractor" }; var newGroups = new List<UnitRenoGrp> { newGrp }; Func<UnitRenoGrp, bool> expression = (existingGrp => existingGrp.RenoGrpName == newGrp.RenoGrpName && existingGrp.hProp == newGrp.hProp && existingGrp.RenoGrpDesc == newGrp.RenoGrpDesc && existingGrp.LeadContractor == newGrp.LeadContractor && existingGrp.ArchiveFlag == newGrp.ArchiveFlag); _entities = new ConstructionEntities(); //remove existing context before test run var existing = _entities.UnitRenoGrps.Where(expression).ToList(); if (existing.Any()) { existing.ForEach(rg => { _entities.UnitRenoGrps.Attach(rg); _entities.UnitRenoGrps.Remove(rg); }); _entities.SaveChanges(); } _target = new UnitRenovationGroupRepository(_entities); _target.Save(newGroups); _result = _target.Retrieve(expression).ToList()[0]; }