private void Update(int id, string name, int age, decimal fee, string bio, DateTime?hiringDate, decimal grossSalary) { try { using (var sitters = new SittersBusiness()) { var entity = new SittersEntity(); entity.SitterID = id; entity.Name = name; entity.Age = age; entity.Fee = fee; entity.Bio = bio; entity.HiringDate = hiringDate; entity.GrossSalary = grossSalary; var opSuccessful = sitters.UpdateSitter(entity); var resultMessage = opSuccessful ? "Done Successfully" : "Error happened or no Sitter found to update"; MessageBox.Show(resultMessage, "Success", MessageBoxButtons.OK); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); MessageBox.Show("UserInterface:SittersForm::Update::Error occured." + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK); } }
private void UpdateSitter(int id, string name, int age, decimal fee, string bio, DateTime?hiringDate, decimal grossSalary, string email, string username, string firstname, string lastname, string password, string role) { try { using (var sitters = new SittersBusiness()) { var entity = new SittersEntity(); entity.SitterID = id; entity.Name = name; entity.Age = age; entity.Fee = fee; entity.Bio = bio; entity.HiringDate = hiringDate; entity.GrossSalary = grossSalary; entity.Username = username; entity.FirstName = firstname; entity.LastName = lastname; entity.Email = email; entity.Password = password; entity.Role = role; var opSuccessful = sitters.UpdateSitter(entity); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); } }
public ActionResult Login(LoginModel info) { using (BusinessLogic.UsersBusiness ctx = new BusinessLogic.UsersBusiness()) { UsersEntity user = ctx.FindUserByUsername(info.Username); if (user == null) { info.message = $"The Username '{info.Username}' does not exist in the database"; return(View(info)); } string actual = user.Password; //string potential = user.Salt + info.Password; string potential = info.Password; bool validateduser = false; if (info.Username.ToLower() == "admin") { validateduser = potential == actual; } else { // check password hash validateduser = System.Web.Helpers.Crypto.VerifyHashedPassword(actual, potential); } if (validateduser) { Session["AUTHUsername"] = user.Username; Session["AUTHRole"] = user.Role; Session["AUTHUserID"] = user.UserID; Session["ChosenOwnerID"] = 0; if (user.Role == "Owner") { using (BusinessLogic.OwnersBusiness ctx2 = new BusinessLogic.OwnersBusiness()) { OwnersEntity owner = ctx2.FindOwnerByUserId(user.UserID); Session["AUTHOwnerID"] = owner.OwnerID; return(Redirect("~/Owners/Details/" + owner.OwnerID)); } } else if (user.Role == "Sitter") { using (BusinessLogic.SittersBusiness ctx2 = new BusinessLogic.SittersBusiness()) { SittersEntity sitter = ctx2.FindSitterByUserId(user.UserID); Session["AUTHSitterID"] = sitter.SitterID; return(Redirect("~/Sitters/Details/" + sitter.SitterID)); } } else if (user.Role == "Admin") { return(Redirect("~/Users/ListAll")); } } info.message = "The password was incorrect"; return(View(info)); } }
// Business Logic pass through code to Update Sitter public bool UpdateSitter(SittersEntity entity) { try { bool bOpDoneSuccessfully; using (var repository = new SittersRepository()) { bOpDoneSuccessfully = repository.Update(entity); } return(bOpDoneSuccessfully); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:SittersBusiness::UpdateSitter::Error occured.", ex); } }
private void InsertSitter(string name, int age, decimal fee, string bio, DateTime?hiringDate, decimal grossSalary) { try { using (var sitters = new SittersBusiness()) { var entity = new SittersEntity(); entity.Name = name; entity.Age = age; entity.Fee = fee; entity.Bio = bio; entity.HiringDate = hiringDate; entity.GrossSalary = grossSalary; var opSuccessful = sitters.InsertSitter(entity); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); } }