public IActionResult OnPost() { SqlCode code; //System.Diagnostics.Debug.WriteLine($"TimeSelected: {TimeSelected}"); //DateTime appointmentDateTime = Date.Add(Time); //counsellorID = SelectedID; //clientID = SelectedClientID; Classes.Appointment appointment = new Classes.Appointment() { AppointmentID = (int)AppointmentID, AppointmentDate = AppointmentDate, ClientID = ClientID, CounsellorID = CounsellorID, Notes = Notes }; System.Diagnostics.Debug.WriteLine("Displaying updated appointment"); appointment.Print(); ResolutionsSystem rs = new ResolutionsSystem(); code = rs.UpdateAppointment(appointment); if (code == SqlCode.Failure) { Message = "Failed to Update appointment"; //return Page(); } return(new RedirectToPageResult("ViewAppointments")); }
public void OnGet() { PopulateFields(); //AvailableTimes = GetAvailableTimes(); PopulateSelectList(); ResolutionsSystem rs = new ResolutionsSystem(); ListOfCounsellors = rs.GetCounsellors(); }
public IActionResult OnGet() { string username = GetSessionValue("Username"); if (username == null || username == string.Empty) { return(new RedirectToPageResult("Index")); } int appointmentID = int.Parse(HttpContext.Session.GetString("UpdateAppointmentID")); System.Diagnostics.Debug.WriteLine($"UpdateAppointment: Updating appointment: {appointmentID}"); ResolutionsSystem rs = new ResolutionsSystem(); Classes.Appointment app = rs.GetAppointment(appointmentID); AppointmentID = app.AppointmentID; AppointmentDate = app.AppointmentDate; Classes.Client client = rs.GetClient(app.ClientID); ClientID = (int)client.ClientID; if (client.MiddleName == null) { ClientFullName = $"{client.FirstName} {client.LastName}"; } else { ClientFullName = $"{client.FirstName} {client.MiddleName} {client.LastName}"; } Classes.Counsellor counsellor = rs.GetCounsellor(app.CounsellorID); CounsellorID = counsellor.CounsellorID; CounsellorName = counsellor.Name; //Message = $"Updating appointment {appointmentID}\n" + // $"Date: {app.AppointmentDate}\n" + // $"Client Name: {clientName} ({client.ClientID})\n" + // $"Counsellor: {counsellor.Name} ({counsellor.CounsellorID})"; System.Diagnostics.Debug.WriteLine($"Updated appointment: {(int)AppointmentID}"); //PopulateFields(app); //counsellors dropdownlist //PopulateSelectList(); //ListOfCounsellors = rs.GetCounsellors(); //client dropdownlist //PopulateSelectListForClient(); //ListOfClients = rs.GetClients(); return(Page()); }
public IActionResult OnGet() { //string username = GetSessionValue("Username"); //if (username == null || username == string.Empty) // return new RedirectToPageResult("Index"); ResolutionsSystem rs = new ResolutionsSystem(); StaffList = rs.GetLogins(); // need GetAllLogins function and stored procedure return(Page()); }
public IActionResult OnPostDelete(int ClientID) { ResolutionsSystem rs = new ResolutionsSystem(); Classes.Client client = new Client() { ClientID = ClientID }; SqlCode code = rs.DeleteClient(client); System.Diagnostics.Debug.WriteLine($"Deleting client {ClientID}"); return(new RedirectToPageResult("ViewClients")); }
public IActionResult OnGet() { string username = GetSessionValue("Username"); if (username == null || username == string.Empty) { return(new RedirectToPageResult("Index")); } ResolutionsSystem rs = new ResolutionsSystem(); ListOfClients = rs.GetClients(); return(Page()); }
public IActionResult OnPost() { ResolutionsSystem rs = new ResolutionsSystem(); Login UpdatedLogin = new Login(); UpdatedLogin.Username = NewUsername; UpdatedLogin.Password = Util.HashPassword(NewPassword); rs.UpdateLogin(UpdatedLogin); HttpContext.Session.Set("ToModifyStaffID", Util.StringToByteArray("")); return(Page()); }
private void AddTestLogin() { string password = Util.HashPassword("password"); //System.Diagnostics.Debug.WriteLine(password); Classes.Login login = new Classes.Login() { Username = "******", Password = password, StaffType = "Counsellor" }; ResolutionsSystem rs = new ResolutionsSystem(); SqlCode code = rs.CreateLogin(login); }
public IActionResult OnGet() { string username = HttpContext.Session.GetString("Username"); System.Diagnostics.Debug.WriteLine($"UpdateStaff username: {username}"); if (username == null || username == string.Empty) { return(new RedirectToPageResult("Index")); } ResolutionsSystem rs = new ResolutionsSystem(); ToUpdateStaff = rs.GetLogin(HttpContext.Session.GetString("Username")); NewUsername = ToUpdateStaff.Username; NewPassword = ToUpdateStaff.Password; return(Page()); }
private void PopulateSelectList() { ResolutionsSystem rs = new ResolutionsSystem(); ListOfCounsellors = rs.GetCounsellors(); SelectCounsellorList = new List <SelectListItem>(); foreach (Counsellor p in ListOfCounsellors) { SelectListItem item = new SelectListItem() { Text = p.Name, Value = p.CounsellorID.ToString() }; SelectCounsellorList.Add(item); } }
public IActionResult OnGet() { string username = GetSessionValue("Username"); if (username == null || username == string.Empty) { return(new RedirectToPageResult("Index")); } if (AppointmentID == null) { return(new RedirectToPageResult("Index")); } ResolutionsSystem rs = new ResolutionsSystem(); SqlCode code = rs.DeleteAppointment((int)AppointmentID); return(new RedirectToPageResult("ViewAppointments")); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } Client AddClient = new Client(); AddClient.FirstName = FName; AddClient.LastName = LName; AddClient.MiddleName = MName; AddClient.Email = Email; AddClient.Phone = Phone; AddClient.Address = Address; ResolutionsSystem rs = new ResolutionsSystem(); SqlCode code = rs.CreateClient(AddClient); return(new RedirectToPageResult("Index")); }
public JsonResult OnPostCheckUsername() { System.Diagnostics.Debug.WriteLine("OnPostCheckUsername()"); ResolutionsSystem rs = new ResolutionsSystem(); Classes.Login login = rs.GetLogin(Username); bool valid = false; if (login.Username == null) { valid = false; } else { valid = true; } return(new JsonResult(valid)); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } System.Diagnostics.Debug.WriteLine("OnPost()"); bool authenticated = false; ResolutionsSystem rs = new ResolutionsSystem(); Classes.Login login = rs.GetLogin(Username); System.Diagnostics.Debug.WriteLine($"Hash pass: {login.Password}"); bool passwordVerified = Util.Verify(Password, login.Password); if (passwordVerified) { authenticated = true; } if (authenticated) { System.Diagnostics.Debug.WriteLine("User authenticated successfully"); HttpContext.Session.Set("Username", Util.StringToByteArray(Username)); HttpContext.Session.Set("StaffType", Util.StringToByteArray(login.StaffType)); return(new RedirectToPageResult("Index")); } else { System.Diagnostics.Debug.WriteLine("Login failed"); return(Page()); } }
public IActionResult OnPost() { System.Diagnostics.Debug.WriteLine("OnPost()"); System.Diagnostics.Debug.WriteLine($"Username: {Username}"); System.Diagnostics.Debug.WriteLine($"Password: {Password}"); System.Diagnostics.Debug.WriteLine($"StaffType: {StaffType}"); //return Page(); if (ModelState.IsValid) { if (Password != PasswordConfirm) { Message = "Passwords do not match"; return(Page()); } ResolutionsSystem rs = new ResolutionsSystem(); Login AddLogin = new Login(); AddLogin.Username = Username; AddLogin.Password = Password; AddLogin.StaffType = StaffType; // This one form can do two things, create a login for staff, AND create a counsellor login // below the code checks and creates 1 or 2 objects respectively depending if there is a counsellor being added or not // edit the SQL stored procedure and resolutionspsych to add new counsellor if needed with the createLogin method path SqlCode code = rs.CreateLogin(AddLogin); //create login no matter what if (StaffType == "Counsellor") { //add counsellor Counsellor newCounsellor = new Counsellor() { Name = CounsellorName }; code = rs.CreateCounsellor(newCounsellor); } /* * if (CounsellorName.Length==0){ * * * SqlCode code = rs.CreateLogin(AddLogin); * } * else * { * Counsellor AddCounsellor = new Counsellor(); * AddCounsellor.Name = CounsellorName; * // SqlCode code = rs.CreateLogin(AddLogin,AddCounsellor); * } */ Message = "New Staff Added"; return(Page()); } else { System.Diagnostics.Debug.WriteLine($"StaffType: {StaffType}"); return(Page()); } }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } ResolutionsSystem rs = new ResolutionsSystem(); Classes.Client client = new Client(); if (MiddleName == null || MiddleName == "") { client = rs.GetClient(FirstName, LastName); } else { client = rs.GetClient(FirstName, MiddleName, LastName); } int counsellorID; SqlCode code; if (client.ClientID == null) { //client doesn't exist System.Diagnostics.Debug.WriteLine("Client doesn't exist"); //client doesn't exist, so insert a new client into the database code = rs.CreateClient(GetClient()); if (code == SqlCode.Failure) { System.Diagnostics.Debug.WriteLine("Failed to create client"); Message = "Failed to create client"; return(Page()); } } else { System.Diagnostics.Debug.WriteLine("Client exists"); } //client now exists if (MiddleName == null || MiddleName == "") { client = rs.GetClient(FirstName, LastName); } else { client = rs.GetClient(FirstName, MiddleName, LastName); } counsellorID = SelectedID; System.Diagnostics.Debug.WriteLine($"TimeSelected: {TimeSelected}"); //TimeSpan appointmentTime = TimeSpan.Parse(TimeSelected); //DateTime appointmentDateTime = Date.Add(appointmentTime); DateTime appointmentDateTime = Date.Add(Time); Classes.Appointment newAppointment = new Classes.Appointment() { AppointmentDate = appointmentDateTime, ClientID = (int)client.ClientID, CounsellorID = counsellorID }; code = rs.BookAppointment(newAppointment); if (code == SqlCode.Failure) { Message = "Failed to create appointment"; return(Page()); } return(new RedirectToPageResult("Index")); }