//---------------------------------------------------- //Create Pilot public static void createPilot(PilotAccount pilot) { pilot.pilotAccount_basket = 0; pilot.pilotAccount_activity = "1"; pilot.pilotAccount_subscriptionDate = DateTime.Now; DbConn.CONN.PilotAccount.AddObject(pilot); DbConn.CONN.SaveChanges(); }
//-------------------------------------------------- //PilotAccount JSON Object public static Object pilotAccount(PilotAccount pilotAccount) { return new { pilotAccount_id = pilotAccount.pilotAccount_id, pilotAccount_firstName = pilotAccount.pilotAccount_firstName, pilotAccount_lastName = pilotAccount.pilotAccount_lastName, pilotAccount_subscriptionDate = FormatHelper.getDate(pilotAccount.pilotAccount_subscriptionDate), pilotAccount_phone = pilotAccount.pilotAccount_phone, pilotAccount_mail = pilotAccount.pilotAccount_mail, pilotAccount_basket = pilotAccount.pilotAccount_basket, pilotAccount_lastModificationDate = FormatHelper.getDateTime(pilotAccount.pilotAccount_lastModificationDate) }; }
//---------------------------------------------------- //Update Pilot public static void updatePilot(PilotAccount pilot, PilotAccount newValues) { if (newValues.pilotAccount_firstName != null) pilot.pilotAccount_firstName = newValues.pilotAccount_firstName; if (newValues.pilotAccount_lastName != null) pilot.pilotAccount_lastName = newValues.pilotAccount_lastName; if (newValues.pilotAccount_mail != null) pilot.pilotAccount_mail = newValues.pilotAccount_mail; if (newValues.pilotAccount_pass != null) pilot.pilotAccount_pass = newValues.pilotAccount_pass; if (newValues.pilotAccount_phone != null) pilot.pilotAccount_phone = newValues.pilotAccount_phone; DbConn.CONN.SaveChanges(); }
public ActionResult updatePassword(long id) { object result; AccountPassword input = AccountPassword.getFromJsonRequest(Request); PilotAccount pilot; if (!FormatHelper.isValidAccountPassword(input)) // No input data { result = ResponseHelper.wrongInput(); } else if (!SessionHelper.isLogged(Session)) // User is not logged { result = ResponseHelper.mustBeLogged(); } else if (!SessionHelper.isPilot(Session, id)) // User tries to update another pilot's password { result = ResponseHelper.forbidden(); } else if ((pilot = PilotAccountEntity.selectById(id)) == null) // Given id does not match any pilot { result = ResponseHelper.notFound("Pilot"); } else if (!SimpleHash.VerifyHash(input.oldPassword, pilot.pilotAccount_pass)) // Old password does not match actual one { result = ResponseHelper.wrongPassword(); } else { PilotAccount newPilot = new PilotAccount(); newPilot.pilotAccount_pass = SimpleHash.ComputeHash(input.newPassword); PilotAccountEntity.updatePilot(pilot, newPilot); result = ResponseHelper.success(); } return Json(result); }
internal static bool isValidPilotAccountEdit(PilotAccount pilot) { return pilot != null && (pilot.pilotAccount_firstName == null || !string.IsNullOrWhiteSpace(pilot.pilotAccount_firstName)) && (pilot.pilotAccount_lastName == null || !string.IsNullOrWhiteSpace(pilot.pilotAccount_lastName)) && (pilot.pilotAccount_mail == null || isValidEmail(pilot.pilotAccount_mail)) && (pilot.pilotAccount_phone == null || isValidPhoneNumber(pilot.pilotAccount_phone)); }
internal static bool isValidPilotAccount(PilotAccount pilot) { return pilot != null && !string.IsNullOrWhiteSpace(pilot.pilotAccount_firstName) && !string.IsNullOrWhiteSpace(pilot.pilotAccount_lastName) && isValidEmail(pilot.pilotAccount_mail) && isValidPassword(pilot.pilotAccount_pass) && isValidPhoneNumber(pilot.pilotAccount_phone); }
/// <summary> /// Méthode déconseillée pour ajouter un nouvel objet à l'EntitySet PilotAccount. Utilisez la méthode .Add de la propriété ObjectSet<T> associée à la place. /// </summary> public void AddToPilotAccount(PilotAccount pilotAccount) { base.AddObject("PilotAccount", pilotAccount); }
/// <summary> /// Créez un nouvel objet PilotAccount. /// </summary> /// <param name="pilotAccount_id">Valeur initiale de la propriété pilotAccount_id.</param> public static PilotAccount CreatePilotAccount(global::System.Int64 pilotAccount_id) { PilotAccount pilotAccount = new PilotAccount(); pilotAccount.pilotAccount_id = pilotAccount_id; return pilotAccount; }
//---------------------------------------------------- //Disable Pilot public static void disablePilot(PilotAccount pilot) { pilot.pilotAccount_activity = "0"; DbConn.CONN.SaveChanges(); }
//---------------------------------------------------- // credits the pilot account public static void debitPilot(PilotAccount pilot, float price) { pilot.pilotAccount_basket = pilot.pilotAccount_basket - price; DbConn.CONN.SaveChanges(); }
//---------------------------------------------------- // Refreshes HTTP Session data for given PilotAccount. // Returns false if sessionID mismatches internal static bool refreshSession(PilotAccount pilot, string sessionID) { if (pilot.pilotAccount_sessionID == sessionID) { pilot.pilotAccount_lastModificationDate = DateTime.Now; DbConn.CONN.SaveChanges(); return true; } else return false; }
//---------------------------------------------------- // Opens an HTTP Session for given PilotAccount internal static void openSession(PilotAccount pilot, string sessionID) { pilot.pilotAccount_lastModificationDate = DateTime.Now; pilot.pilotAccount_sessionID = sessionID; DbConn.CONN.SaveChanges(); }