Example #1
0
 public void RemovePolicy(string type, string subject)
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("AdminView", "Trying to remove policy.");
         CheckInput(type, subject);
         _manager.RemovePolicy(GetPolicyType(type), subject);
         MarketLog.Log("AdminView", "Policy removed successfully.");
         Answer = new AdminAnswer(EditPolicyStatus.Success, "Policy removed.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(EditPolicyStatus.NoAuthority, e.GetErrorMessage());
     }
 }
Example #2
0
 public void ViewPolicies()
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         Category[]    catList = _adminDL.GetAllCategories();
         List <string> result  = new List <string>();
         foreach (var cat in catList)
         {
             result.Add(cat.Name);
         }
         Answer = new AdminAnswer(ViewPolicyStatus.Success, "Successfully got all category names.", result.ToArray());
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(ViewPolicyStatus.NoAuthority, e.GetErrorMessage(), null);
     }
 }
Example #3
0
 public void AddCategory(string categoryName)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to add category to the store");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("StoreCenter", " check if category name exists");
         CheckIfCategoryExists(categoryName);
         MarketLog.Log("StoreCenter", " adding category");
         if (categoryName.IsNullOrEmpty())
         {
             Answer = new AdminAnswer(EditCategoryStatus.InvalidCategory, "The category name is empty!");
             return;
         }
         Category category = new Category(categoryName);
         _adminDlInstacne.AddCategory(category);
         Answer = new AdminAnswer(EditCategoryStatus.Success, "Category " + categoryName + " added.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
 }
Example #4
0
 public void ViewPolicies()
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("AdminView", "Trying to view policies.");
         string[] result = _manager.ViewPolicies();
         MarketLog.Log("AdminView", "Successfully got policiy ids.");
         Answer = new AdminAnswer(ViewPolicyStatus.Success, "Successfully got policiy ids.", result);
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(ViewPolicyStatus.NoAuthority, e.GetErrorMessage(), null);
     }
 }
Example #5
0
 public void CreatePolicy(string type, string subject, string op, string arg1, string optArg)
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("AdminView", "Trying to add policy.");
         BuildPolicy(type, subject, op, arg1, optArg);
         MarketLog.Log("AdminView", " Adding policy successfully.");
         Answer = new AdminAnswer(EditPolicyStatus.Success, "Policy created.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(EditPolicyStatus.NoAuthority, e.GetErrorMessage());
     }
 }
Example #6
0
 private void ViewPurchaseHistory(string field, string givenValue)
 {
     try
     {
         _admin.ValidateSystemAdmin();
         var historyReport = _adminDB.GetPurchaseHistory(field, givenValue);
         Answer = new AdminAnswer(ViewPurchaseHistoryStatus.Success,
                                  "View purchase history has been successful!", historyReport);
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((ViewPurchaseHistoryStatus)e.Status, e.GetErrorMessage(), null);
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(ViewPurchaseHistoryStatus.NotSystemAdmin, e.GetErrorMessage(), null);
     }
 }
Example #7
0
 public void ViewLog()
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to view system log");
         _admin.ValidateSystemAdmin();
         var eventLogReport = _adminDlInstacne.GetEventLogReport();
         Answer = new AdminAnswer(ViewSystemLogStatus.Success, "Successfully retrived the system log entries!", eventLogReport);
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((ViewSystemLogStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer(ViewSystemLogStatus.NoDB, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(ViewSystemLogStatus.NotSystemAdmin, e.GetErrorMessage());
     }
 }
Example #8
0
 public void GetEntranceDetails()
 {
     try
     {
         MarketLog.Log("UserSpot", "User " + adminSystemID + " attempting to view entrance details...");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("UserSpot", "User " + adminSystemID + " has successfully retrieved all entrance information...");
         Answer = new AdminAnswer(GetEntranceDetailsEnum.Success, "View of Entrance report successfully!",
                                  GetDataAsString(GetDetails()));
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((GetEntranceDetailsEnum)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((GetEntranceDetailsEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(GetEntranceDetailsEnum.NoAuthority, e.GetErrorMessage(), null);
     }
 }
Example #9
0
        public void RemoveUser(string userName)
        {
            try
            {
                MarketLog.Log("AdminView", "System Admin " + adminSystemID +
                              " attempting to execute remove user operation on User " + userName + "...");
                _admin.ValidateSystemAdmin();
                ApproveNotSelfTermination(userName);
                ValidateUserExist(userName);
                MarketLog.Log("AdminView", "User " + userName +
                              " has been found by the system. Removing user's saved cart and profile...");

                _adminDB.DeleteUser(userName);
                MarketLog.Log("AdminView", "System Admin " + adminSystemID +
                              " successfully removed User " + userName + " from the system!");

                MarketLog.Log("AdminView", "looking for sole ownership of User " + userName + " on stores...");
                RemoveSolelyOwnedStores(userName);

                MarketLog.Log("AdminView", "User " + userName +
                              " solely owned stores has been deactivated. Operation is " +
                              "finally completed safely!");
                Answer = new AdminAnswer(RemoveUserStatus.Success, "Remove user has been successful!");
            }
            catch (AdminException e)
            {
                Answer = new AdminAnswer((RemoveUserStatus)e.Status, e.GetErrorMessage());
            }
            catch (DataException e)
            {
                Answer = new AdminAnswer((RemoveUserStatus)e.Status, e.GetErrorMessage());
            }
            catch (MarketException e)
            {
                Answer = new AdminAnswer(RemoveUserStatus.NotSystemAdmin, e.GetErrorMessage());
            }
        }