Example #1
0
 //--------------------------------------------------
 //Secretary JSON Object
 public static Object secretary(Secretary secretary)
 {
     return new
     {
         secretary_id = secretary.secretary_id,
         secretary_firstName = secretary.secretary_firstName,
         secretary_lastName = secretary.secretary_lastName,
         secretary_subscriptionDate = FormatHelper.getDate(secretary.secretary_subscriptionDate),
         secretary_phone = secretary.secretary_phone,
         secretary_mail = secretary.secretary_mail,
         secretary_lastModificationDate = FormatHelper.getDateTime(secretary.secretary_lastModificationDate)
     };
 }
Example #2
0
 //----------------------------------------------------
 // Refreshes HTTP Session data for given Secretary.
 // Returns false if sessionID mismatches
 internal static bool refreshSession(Secretary secretary, string sessionID)
 {
     if (secretary.secretary_sessionID == sessionID)
     {
         secretary.secretary_lastModificationDate = DateTime.Now;
         DbConn.CONN.SaveChanges();
         return true;
     }
     else
     {
         return false;
     }
 }
Example #3
0
 //----------------------------------------------------
 // Update Secretary
 internal static void updateSecretary(Secretary secretary, Secretary newValues)
 {
     if (newValues.secretary_firstName != null)
         secretary.secretary_firstName = newValues.secretary_firstName;
     if (newValues.secretary_lastName != null)
         secretary.secretary_lastName = newValues.secretary_lastName;
     if (newValues.secretary_mail != null)
         secretary.secretary_mail = newValues.secretary_mail;
     if (newValues.secretary_pass != null)
         secretary.secretary_pass = newValues.secretary_pass;
     if (newValues.secretary_phone != null)
         secretary.secretary_phone = newValues.secretary_phone;
     DbConn.CONN.SaveChanges();
 }
Example #4
0
 //----------------------------------------------------
 // Opens an HTTP Session for given Secretary
 internal static void openSession(Secretary secretary, string sessionID)
 {
     secretary.secretary_lastModificationDate = DateTime.Now;
     secretary.secretary_sessionID = sessionID;
     DbConn.CONN.SaveChanges();
 }
Example #5
0
 //----------------------------------------------------
 // Disable Secretary
 internal static void disableSecretary(Secretary secretary)
 {
     secretary.secretary_activity = "0";
     DbConn.CONN.SaveChanges();
 }
Example #6
0
 //----------------------------------------------------
 // Create Secretary
 internal static void createSecretary(Secretary secretary)
 {
     DbConn.CONN.Secretary.AddObject(secretary);
     DbConn.CONN.SaveChanges();
 }
Example #7
0
 internal static bool isValidSecretary(Secretary secretary)
 {
     return secretary != null
         && !string.IsNullOrWhiteSpace(secretary.secretary_firstName)
         && !string.IsNullOrWhiteSpace(secretary.secretary_lastName)
         && isValidEmail(secretary.secretary_mail)
         && isValidPhoneNumber(secretary.secretary_phone);
 }
 /// <summary>
 /// Méthode déconseillée pour ajouter un nouvel objet à l'EntitySet Secretary. Utilisez la méthode .Add de la propriété ObjectSet&lt;T&gt; associée à la place.
 /// </summary>
 public void AddToSecretary(Secretary secretary)
 {
     base.AddObject("Secretary", secretary);
 }
 /// <summary>
 /// Créez un nouvel objet Secretary.
 /// </summary>
 /// <param name="secretary_id">Valeur initiale de la propriété secretary_id.</param>
 public static Secretary CreateSecretary(global::System.Int64 secretary_id)
 {
     Secretary secretary = new Secretary();
     secretary.secretary_id = secretary_id;
     return secretary;
 }
Example #10
0
 public ActionResult updatePassword(long id)
 {
     object result;
     AccountPassword input = AccountPassword.getFromJsonRequest(Request);
     Secretary secretary;
     if (!FormatHelper.isValidAccountPassword(input))
     {
         result = ResponseHelper.wrongInput();
     }
     else if (!SessionHelper.isLogged(Session))
     {
         result = ResponseHelper.mustBeLogged();
     }
     else if (!SessionHelper.isSecretary(Session, id) && !SessionHelper.isSuperAdmin(Session))
     {
         result = ResponseHelper.forbidden();
     }
     else if ((secretary = SecretaryEntity.selectById(id)) == null)
     {
         result = ResponseHelper.notFound("Secretary");
     }
     else if (!SimpleHash.VerifyHash(input.oldPassword, secretary.secretary_pass))
     {
         result = ResponseHelper.wrongPassword();
     }
     else try
     {
         Secretary newValues = new Secretary();
         newValues.secretary_pass = SimpleHash.ComputeHash(input.newPassword);
         SecretaryEntity.updateSecretary(secretary, newValues);
         result = ResponseHelper.success();
     }
     catch (Exception ex)
     {
         result = SqlResponseHandler.getError(ex);
     }
     return Json(result);
 }