Example #1
0
 /// <summary>
 /// Deletes the login with the given stringId
 /// </summary>
 /// <param name="stringId"></param>
 public int DeleteUser(string stringId)
 {
     try
     {
         var id = Int64.Parse(stringId);
         using (var db = new ReportAppLoginEntities())
         {
             db.Login.Remove(db.Login.FirstOrDefault(x => x.ID == id));
             db.SaveChanges();
         }
         return (int)codes.success;
     }
     catch (Exception e)
     {
         return (int)codes.fail;
     }
 }
Example #2
0
 /// <summary>
 /// Creates a login with the given parameters
 /// </summary>
 /// <param name="login"></param>
 public int CreateLogin(LoginDTO login)
 {
     try
     {
         using (var db = new ReportAppLoginEntities())
         {
             db.Login.Add(new Login()
             {
                 Username = login.Username,
                 Password = login.Password
             });
             db.SaveChanges();
         }
         return (int)codes.success;
     }
     catch (DbUpdateException e)
     {
         return (int)codes.user_exists;
     }
     catch (Exception e)
     {
         return (int)codes.fail;
     }
 }