예제 #1
0
        public static void AddOrUpdate(Admins Item, cap01devContext db)
        {
            try
            {
                Logger.Trace("Admins.Update IN");

                db.Update <Admins>(Item);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Update user error");
                throw new Exception("Update user error", ex);
            }
            finally
            {
                Logger.Trace("Admins.Delete OUT");
            }
        }
예제 #2
0
        public static void Disable(string userLogin, cap01devContext db)
        {
            try
            {
                Logger.Trace("Admins.Disable IN");
                Logger.Debug("Admins.Disable userLogin: {0}", userLogin);

                Admins item = GetUserByLogin(userLogin, db);
                if (item != null)
                {
                    Logger.Debug("User founded");
                    Logger.Debug("Admins.Disable user_id: {0}", item.Id);
                    item.Disable();
                    db.Update <Admins>(item);
                    db.SaveChanges();
                }
                else
                {
                    Logger.Debug("User not founded");
                    throw new KeyNotFoundException("User not founded");
                }
            }
            catch (KeyNotFoundException ex)
            {
                Logger.Error(ex, $"User {userLogin} not exist");
                throw new KeyNotFoundException("Test user password error", ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Disable user error");
                throw new Exception("Disable user error", ex);
            }
            finally
            {
                Logger.Trace("Admins.Disable OUT");
            }
        }