public async Task <IActionResult> HouseOwnerRegister(HouseOwnerRegisterModel model) { if (ModelState.IsValid) { var user = await userManagerHO.FindByNameAsync(model.NID); //var nid = await userManager.FindbyNidAsync(model.NID); if (user == null) { user = new HouseOwner { Id = Guid.NewGuid().ToString(), Name = model.Name, Mobile = model.Mobile, NID = model.NID, Email = model.Email }; var result = await userManagerHO.CreateAsync(user, model.Password); if (result.Succeeded) { return(View("Success")); } } else { //ModelState.AddModelError("NID", _localizer["NID already exists"]); ViewBag.HOError = "HO"; } } return(View("HouseOwner")); }
public IActionResult Edit(int id, [Bind("Id,Name,ContactNumber")] HouseOwner houseOwner) { if (id != houseOwner.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(houseOwner); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HouseOwnerExists(houseOwner.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(houseOwner)); }
public ActionResult DeleteConfirmed(int id) { HouseOwner houseOwner = db.HouseOwners.Find(id); db.HouseOwners.Remove(houseOwner); db.SaveChanges(); return(RedirectToAction("Index")); }
//Adds a house owner. public IActionResult Create([Bind("Id,Name,ContactNumber")] HouseOwner houseOwner) { if (ModelState.IsValid) { _context.Add(houseOwner); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(houseOwner)); }
public ActionResult Edit([Bind(Include = "Id,Name,NationalId,MobileNo,OccupationId,UserName,Password,ConfirmPassword")] HouseOwner houseOwner) { if (ModelState.IsValid) { db.Entry(houseOwner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseOwner.OccupationId); return(View(houseOwner)); }
// GET: HouseOwners/Details/5 public ActionResult Details(HouseOwner houseOwner) { var houseOwners = db.HouseOwners.ToList(); HouseOwner houseOwnerRegInf = houseOwners.Find(a => a.NationalId == houseOwner.NationalId); if (houseOwner == null) { return(HttpNotFound()); } return(View(houseOwner)); }
//Inserts a new houseOwner into the Db public void Insert(HouseOwner houseOwner) { using (IDbConnection conn = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("SydvestBo"))) { string sql = "INSERT INTO HouseOwners ([name]) Values (@name);"; var affectedRows = conn.Execute(sql, houseOwner); Console.WriteLine($"New Owner '{houseOwner.name}' added!"); Console.ReadKey(); } }
private void GetJsonForDatagrid(HttpContext context) { int totalRecords = 0; int pageIndex = 1; int pageSize = 10; int.TryParse(context.Request.QueryString["page"], out pageIndex); int.TryParse(context.Request.QueryString["rows"], out pageSize); string sqlWhere = string.Empty; ParamsHelper parms = null; if (!string.IsNullOrEmpty(context.Request.QueryString["houseOwnerName"])) { sqlWhere = "and HouseOwnerName like @HouseOwnerName "; SqlParameter parm = new SqlParameter("@HouseOwnerName", SqlDbType.NVarChar, 50); parm.Value = "%" + context.Request.QueryString["houseOwnerName"].Trim() + "%"; if (parms == null) { parms = new ParamsHelper(); } parms.Add(parm); } if (!string.IsNullOrEmpty(context.Request.QueryString["houseId"])) { sqlWhere = "and HouseId = @HouseId "; SqlParameter parm = new SqlParameter("@HouseId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(context.Request.QueryString["houseId"].Trim()); if (parms == null) { parms = new ParamsHelper(); } parms.Add(parm); } HouseOwner bll = new HouseOwner(); var list = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms != null ? parms.ToArray() : null); if (list == null || list.Count == 0) { context.Response.Write("{\"total\":0,\"rows\":[]}"); return; } StringBuilder sb = new StringBuilder(); foreach (var model in list) { sb.Append("{\"Id\":\"" + model.Id + "\",\"HouseOwnerName\":\"" + model.HouseOwnerName + "\",\"MobilePhone\":\"" + model.MobilePhone + "\",\"CompanyName\":\"" + model.CompanyName + "\",\"CommunityName\":\"" + model.CommunityName + "\",\"BuildingCode\":\"" + model.BuildingCode + "\",\"UnitCode\":\"" + model.UnitCode + "\",\"HouseCode\":\"" + model.HouseCode + "\"},"); } context.Response.Write("{\"total\":" + totalRecords + ",\"rows\":[" + sb.ToString().Trim(',') + "]}"); }
// GET: HouseOwners/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HouseOwner houseOwner = db.HouseOwners.Find(id); if (houseOwner == null) { return(HttpNotFound()); } return(View(houseOwner)); }
// GET: HouseOwners/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HouseOwner houseOwner = db.HouseOwners.Find(id); if (houseOwner == null) { return(HttpNotFound()); } ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseOwner.OccupationId); return(View(houseOwner)); }
//Gets the house owner for update using a lamda query. public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } HouseOwner = _context.HouseOwner.FirstOrDefault(m => m.Id == id); if (HouseOwner == null) { return(NotFound()); } return(Page()); }
private void Bind(ref string myDataAppend) { if (!Id.Equals(Guid.Empty)) { Page.Title = "编辑楼单元信息"; HouseOwner bll = new HouseOwner(); HouseOwnerInfo model = bll.GetModelByJoin(Id); if (model != null) { txtName.Value = model.HouseOwnerName.Trim(); txtMobilePhone.Value = model.MobilePhone.Trim(); txtTelPhone.Value = model.TelPhone.Trim(); myDataAppend += "{ \"Id\":\"" + model.Id + "\",\"PropertyCompanyId\":\"" + model.PropertyCompanyId + "\",\"ResidenceCommunityId\":\"" + model.ResidenceCommunityId + "\",\"ResidentialBuildingId\":\"" + model.ResidentialBuildingId + "\",\"ResidentialUnitId\":\"" + model.ResidentialUnitId + "\",\"HouseId\":\"" + model.HouseId + "\",\"CompanyName\":\"" + model.CompanyName + "\",\"CommunityName\":\"" + model.CommunityName + "\",\"BuildingCode\":\"" + model.BuildingCode + "\",\"UnitCode\":\"" + model.UnitCode + "\",\"HouseCode\":\"" + model.HouseCode + "\"}"; } } }
private void Bind() { //查询条件 GetSearchItem(); List <HouseOwnerInfo> list = null; int totalRecords = 0; HouseOwner bll = new HouseOwner(); list = bll.GetListByJoin(pageIndex, pageSize, out totalRecords, sqlWhere, orderBy, parms == null ? null : parms.ToArray()); rpData.DataSource = list; rpData.DataBind(); myDataAppend += "<div id=\"myDataForPage\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"; myDataAppend += "<div id=\"myDataForSearch\">[{\"parentType\":\"" + parentType + "\",\"keyword\":\"" + keyword + "\"}]</div>"; }
//Deletes an existing houseOwner from the Db public void Delete(HouseOwner houseOwner) { using (IDbConnection conn = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("SydvestBo"))) { string sql = "DELETE FROM HouseOwners WHERE id = (@id);"; try { var affectedRows = conn.Execute(sql, houseOwner); Console.WriteLine($"Owner {houseOwner.name} ({houseOwner.id}) deleted!"); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }
//Updates an existing houseOwner in the Db public void Change(HouseOwner houseOwner) { using (IDbConnection conn = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("SydvestBo"))) { string sql = "UPDATE HouseOwners SET name = (@name) WHERE id = (@id);"; try { var affectedRows = conn.Execute(sql, houseOwner); Console.WriteLine($"Owner {houseOwner.id} updated!"); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }
//Removes the house owner uses linq to select house owner public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } HouseOwner = (from houseOwner in _context.HouseOwner where houseOwner.Id == id select houseOwner).FirstOrDefault(); if (HouseOwner != null) { _context.HouseOwner.Remove(HouseOwner); _context.SaveChanges(); } return(RedirectToPage("./Index")); }
public ActionResult Index(HouseOwner houseOwner) { var houseOwners = db.HouseOwners.ToList(); HouseOwner houseOwnerSearch = houseOwners.Find(a => a.MobileNo == houseOwner.MobileNo && a.Password == houseOwner.Password); if (houseOwnerSearch != null) { Session["HouseOwnerMobileNo"] = houseOwnerSearch.MobileNo; Session["HouseOwnerName"] = houseOwnerSearch.Name; Session["HouseOwnerId"] = houseOwnerSearch.Id; return(RedirectToAction("Index", "Homes")); } else { ViewBag.LogInError = "Either Password or UserName Not match!"; return(View()); } }
public ActionResult Create(HouseOwner houseOwner) { ViewBag.OccupationId = new SelectList(db.Occupations, "Id", "Name", houseOwner.OccupationId); if (ModelState.IsValid) { var nationalIdWithMobileNos = db.NationalIdWithMobileNos.ToList(); var houseOwners = db.HouseOwners.ToList(); ViewBag.NationalId = nationalIdWithMobileNos.Find(a => a.NationalId == houseOwner.NationalId && a.MobileNo == houseOwner.MobileNo); ViewBag.ExistNationalId = houseOwners.Find(a => a.NationalId == houseOwner.NationalId); if (ViewBag.NationalId != null && ViewBag.ExistNationalId == null) { db.HouseOwners.Add(houseOwner); db.SaveChanges(); var houseOwners2 = db.HouseOwners.ToList(); HouseOwner houseOwnerSearch = houseOwners2.Find(a => a.MobileNo == houseOwner.MobileNo && a.Password == houseOwner.Password); Session["HouseOwnerMobileNo"] = houseOwnerSearch.MobileNo; Session["HouseOwnerName"] = houseOwnerSearch.Name; Session["HouseOwnerId"] = houseOwnerSearch.Id; return(RedirectToAction("Index", "Homes")); } else { if (ViewBag.NationalId == null) { ViewBag.NationalIdFound = "Id not Found"; } return(View()); } } return(View(houseOwner)); }
public House(HouseOwner owner, IList <Floor> floors) { this.Owner = owner; this.Floors = floors; }
public House(HouseOwner owner, Downstairs downstairs, Upstairs upstairs) { this.Downstairs = downstairs; this.Upstairs = upstairs; }
static void Main(string[] args) { bool userAllowed = false; while (!userAllowed) { Console.Write("Username: "******"Password: "******"admin" && pwd == "admin") //All ok { userAllowed = true; } else //Wrong un/pwd - try again { Console.Clear(); Console.WriteLine("Username or password incorrect, try again..."); } } ConsoleKey mainKey = new ConsoleKey(); while (mainKey != ConsoleKey.Escape) { Console.Clear(); Console.WriteLine("Press any key to start, Escape to exit..."); if ((mainKey = Console.ReadKey().Key) != ConsoleKey.Escape) { Console.Clear(); Console.WriteLine("Sydvest-Bo - H1 Case\n"); //Save the input and make it lowercase string answer = Functionality.Select(new string[] { "Houses", "Owners", "Reservations", "Areas", "Seasons", "Inspectors", "Consultants", "Standards", "Weeks" }).ToLower(); Console.Clear(); object controlObj; string targetTable; bool validAnswer = true; switch (answer) { case "houses": controlObj = new House(); targetTable = "Houses"; break; case "owners": controlObj = new HouseOwner(); targetTable = "HouseOwners"; break; case "reservations": controlObj = new Reservation(); targetTable = "Reservations"; break; case "areas": controlObj = new Area(); targetTable = "Areas"; break; case "seasons": controlObj = new Season(); targetTable = "SeasonPrices"; break; case "inspectors": controlObj = new Inspector(); targetTable = "Inspectors"; break; case "consultants": controlObj = new Consultant(); targetTable = "Consultants"; break; case "standards": controlObj = new Standard(); targetTable = "Standards"; break; case "weeks": controlObj = new Week(); targetTable = "Weeks"; break; default: controlObj = new object(); targetTable = ""; validAnswer = false; break; } if (validAnswer) { //Save the input and make it lowercase string action = Functionality.Select(new string[] { "View", "Create", "Update", "Delete" }).ToLower(); Console.Clear(); switch (action) { case "view": SqlHandler.View(controlObj, targetTable); break; case "create": SqlHandler.Create(controlObj, targetTable); break; case "update": SqlHandler.Update(controlObj, targetTable, typeof(Area)); break; case "delete": SqlHandler.Delete(controlObj, targetTable); break; } } else { Console.WriteLine("No match, try again..."); } Console.ReadKey(); } } }
public bool AddHouse(HouseModel newHouseModel) { District checkDistrictHouseIsLocated = GetDistrictByName(newHouseModel.districtHouseIsLocated); if (checkDistrictHouseIsLocated == null) { return(false); } LocationsInDistrict checkLocationInDistrict = GetLocationInDistrictByName(checkDistrictHouseIsLocated.districtID, newHouseModel.locationInDistrict); if (checkLocationInDistrict == null) { return(false); } HouseState checkHouseState = GetHouseStatesByName(newHouseModel.houseState); if (checkHouseState == null) { return(false); } FenceType checkFenceType = GetFenceTypeByName(newHouseModel.fenceType); if (checkFenceType == null) { return(false); } int activatedState = _fieldStateManagement.GetActivatedState().fieldStateID; House newHouse = new House() { districtHouseIsLocated = checkDistrictHouseIsLocated.districtID, locationWithInDistrict = checkLocationInDistrict.districtLocationID, bedrooms = newHouseModel.bedrooms, masterBedroomEnsuite = newHouseModel.masterBedroomEnsuite, selfContained = newHouseModel.selfContained, numberOfGarages = newHouseModel.numberOfGarages, fenceType = checkFenceType.fenceTypeID, dateHouseWillBeAvailable = Convert.ToDateTime(newHouseModel.dateHouseWillBeAvailable), price = newHouseModel.price, modeOfPayment = Convert.ToInt32(newHouseModel.modeOfPayment), dateUploaded = DateTime.Now, description = newHouseModel.description, currentHouseState = checkHouseState.houseStateID, state = activatedState }; HouseContactDetail houseContactDetail = new HouseContactDetail() { houseID = newHouse.houseID, phoneNumber1 = newHouseModel.phoneNumber1, phoneNumber2 = newHouseModel.phoneNumber2, whatsAppContactNumber = newHouseModel.whatsAppContactNumber, email = newHouseModel.email, state = activatedState }; HouseOwner setHouseOwner = new HouseOwner() { userID = newHouseModel.userId, houseID = newHouseModel.houseID, status = activatedState }; TipezeNyumbaUnitOfWork.Repository <House>().Add(newHouse); TipezeNyumbaUnitOfWork.Repository <HouseContactDetail>().Add(houseContactDetail); TipezeNyumbaUnitOfWork.Repository <HouseOwner>().Add(setHouseOwner); TipezeNyumbaUnitOfWork.SaveChanges(); return(true); }