// G e t C l e r k EditClerkModel ICLerkService.GetClerk(int ID) { IClerkDAO ClerkData = new ClerkDAO(); Clerk DBClerk = ClerkData.GetClerk(ID); EditClerkModel WebClerk = new EditClerkModel(); WebClerk.DatabaseID = Convert.ToString(ID); WebClerk.ClerkID = DBClerk.ClerkID; WebClerk.ClerkName = DBClerk.Whom; WebClerk.Password = HidePassword(" "); return(WebClerk); }
bool ICLerkService.AddClerk(String MerchantID, AddClerkModel WebPageData) { String ResultMessage = ""; using (GiftEntities GiftEntity = new GiftEntities()) { IClerkDAO ClerkData = new ClerkDAO(GiftEntity); Clerk ClerkToAdd = new Clerk(); // verify that this is not a duplicate clerk at this merchant location IMerchantDAO MerchantData = new MerchantDAO(GiftEntity); Merchant Merch = MerchantData.GetMerchant(MerchantID); Clerk Duplicate = ClerkData.GetClerk(Merch.MerchantGUID, WebPageData.ClerkID); if (Duplicate != null) { throw new Exception("Clerk ID already in system"); } // this is something that would make sense to have in a transaction // but to do that would require a DAO that can have the // connection defined outside of it. String ClerkUserName = GetUniqueClerkUserName(WebPageData.ClerkName); ClerkToAdd.Whom = WebPageData.ClerkName; ClerkToAdd.ClerkID = WebPageData.ClerkID; ClerkToAdd.UserName = ClerkUserName; ClerkData.CreateClerk(MerchantID, ClerkToAdd); String ClerkEmail = GetUniqueClerkEmail(MerchantID, ClerkUserName); // we also need to define this "user name" in the system MembershipUser user = AddClerkToUsers(ClerkUserName, ClerkEmail, WebPageData.ClerkPassword, out ResultMessage); if (user == null) { throw new Exception(ResultMessage); } // and give it the clerk role AddUserToClerkRole(ClerkUserName); } return(true); }
bool ICLerkService.DeleteClerk(int ClerkID) { using (var GiftEntity = new GiftEntities()) { IClerkDAO ClerkData = new ClerkDAO(); Clerk tClerk = ClerkData.GetClerk(ClerkID); IUserDAO UserData = new UserDAO(); UserData.DeleteUser(tClerk.UserName); IUserInRolesDAO UserRolesData = new UserInRolesDAO(); UserRolesData.DeleteUserFromRole(tClerk.UserName); ClerkData.DeleteClerk(ClerkID); } return(true); }