public void RemoveApprovalStatus() { StoreOwnertshipApprovalStatus test = new StoreOwnertshipApprovalStatus(1, true, "guy"); DbManager.Instance.InsertStoreOwnerShipApprovalStatus(test); DbManager.Instance.DeleteSingleApprovalStatus(test); }
public Tuple <bool, string> ApproveAppoitment(string owner, string Appointed, int storeID, bool approval) { Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod()); if (owner == null || Appointed == null) { Logger.logError(CommonStr.ArgsTypes.None, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "Null Arguments")); } if (owner == "" || Appointed == "") { Logger.logError(CommonStr.ArgsTypes.Empty, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "Blank Arguemtns\n")); } Store store = storeManagment.getStore(storeID); if (store is null) { return(new Tuple <bool, string>(false, "Store Does not Exist")); } User appointer = UM.GetAtiveUser(owner); User appointed = UM.GetUser(Appointed); if (appointer is null || appointed is null) { return(new Tuple <bool, string>(false, "One of the users is not logged Exist\n")); } if (appointer.isguest() || appointed.isguest()) { return(new Tuple <bool, string>(false, "One of the users is a Guest\n")); } //Remove this approvalRequest if (appointer.INeedToApproveRemove(storeID, Appointed)) { //Remove The Pending for the user if (appointed.RemoveOtherApprovalRequest(storeID, owner)) { //Remove Need to Approve From DB try { NeedToApprove ndap = DbManager.Instance.GetNeedToApprove(owner, Appointed, storeID); DbManager.Instance.DeleteSingleApproval(ndap); } catch (Exception ex) { Logger.logError("DeleteSingleApproval error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "Delete Operation from DB Failed cannot proceed")); } } } //Set to false if False and the operation will fail. if (!approval) { RemoveCnadidate(owner, Appointed, storeID); appointed.SetApprovalStatus(storeID, approval); //Update The Approval Status in the DB //Remove MasterAppointer - Candidtae Table from DB string masterNmae = appointed.MasterAppointer[storeID]; appointed.RemoveMasterAppointer(storeID); try { StoreOwnertshipApprovalStatus status = DbManager.Instance.getApprovalStat(Appointed, storeID); CandidateToOwnership cand = DbManager.Instance.GetCandidateToOwnership(Appointed, masterNmae, storeID); Publisher.Instance.Notify(Appointed, new NotifyData("Your request to be an Owner to Store - " + storeID + " Didn't Approved")); DbManager.Instance.DeApprovalTransaction(status, approval, cand, true); //DbManager.Instance.DeleteSingleCandidate(cand); //DbManager.Instance.UpdateApprovalStatus(status, approval); } catch (Exception ex) { Logger.logError("De-Approval db error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "De-Approval Operation from DB Failed cannot proceed")); } return(new Tuple <bool, string>(true, "User failed to become an owner")); } if (appointed.CheckSApprovalStatus(storeID)) { RemoveCnadidate(owner, Appointed, storeID); //User can be assigned to Store owner appointed.RemoveApprovalStatus(storeID); string Mappointer = appointed.MasterAppointer[storeID]; //Add Store Ownership in store Liav is incharge of this if (!appointed.addStoreOwnership(storeID, Mappointer).Item1) { StoreOwner so = DbManager.Instance.getStoreOwnerbyStore(appointed.getUserName(), store.Id); DbManager.Instance.DeleteStoreOwner(so, true); return(new Tuple <bool, string>(false, "Failed to insert store owner to DB memory")); } appointed.AppointerMasterAppointer(storeID); if (!store.AddStoreOwner(appointed)) { return(new Tuple <bool, string>(false, "Failed to insert store owner to DB memory")); } insertAppointment(owner, Appointed, storeID); if (store.IsStoreManager(appointed)) { try { StoreManagersAppoint Sma = DbManager.Instance.GetSingleManagerAppoints(appointed.Store_Managment[storeID], appointed.Name, storeID); DbManager.Instance.DeleteSingleManager(Sma); } catch (Exception ex) { Logger.logError("Remove Store Manager db error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "Could not Remove Manager store from DB")); } store.RemoveManager(appointed); appointed.RemoveStoreManagment(storeID); } Publisher.Instance.Notify(Appointed, new NotifyData("Your request to be an Owner to Store - " + storeID + " is Approved")); Tuple <bool, string> ans = Publisher.Instance.subscribe(Appointed, storeID); try { CandidateToOwnership cand = DbManager.Instance.GetCandidateToOwnership(Appointed, Mappointer, storeID); DbManager.Instance.DeleteSingleCandidate(cand); //Delete Approval Status from DB StoreOwnertshipApprovalStatus status = DbManager.Instance.getApprovalStat(Appointed, storeID); DbManager.Instance.DeleteSingleApprovalStatus(status); DbManager.Instance.SaveChanges(); } catch (Exception ex) { Logger.logError("Inser Store Owner db error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod()); return(new Tuple <bool, string>(false, "Inser Store Owner Operation from DB Failed cannot proceed")); } return(ans); } DbManager.Instance.SaveChanges(); return(new Tuple <bool, string>(true, "User Still has some Work to do before he can become an Owner of this Store.")); }