public ActionResult PharmacySelect(int pharmacy) { User.setPharmacy(pharmacy); if (pharmacy > -1) { using (var service = new PharmacistService()) { var pharmacist = service.GetWhere(PharmacistService.EmailCol == User.Email).FirstOrDefault(); var serializedPharmacist = new PPOKPrincipalSerializeModel(pharmacist, pharmacy); //serializedPharmacist.Pharmacy = User.Pharmacy; makeAuthTicket(serializedPharmacist); } return(RedirectToAction("Index", "LandingPage")); } else { using (var service = new SystemAdminService()) { var admin = service.GetWhere(SystemAdminService.EmailCol == User.Email).FirstOrDefault(); var serializedAdmin = new PPOKPrincipalSerializeModel(admin); serializedAdmin.Pharmacy = User.Pharmacy; makeAuthTicket(serializedAdmin); } return(RedirectToAction("Index", "SystemAdmin")); } }
public void NotSystemAdminTest() { userServiceSession.EnterSystem(); userServiceSession.SignIn("Arik2", "123"); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)EditPolicyStatus.NoAuthority, adminServiceSession.CreatePolicy("Global", null, "Quantity <=", "5", "0").Status); }
public void AddSimplePolicySuccess() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.CreatePolicy("Global", null, "Quantity <=", "5", "0").Status); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.SavePolicy().Status); }
public void RemoveUserInputFailTest() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)RemoveUserStatus.BadInput, adminServiceSession.RemoveUser(badUserName).Status); Assert.IsTrue(MarketException.HasErrorRaised()); }
public void DidntLoggedTest() { userServiceSession.EnterSystem(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)ViewPurchaseHistoryStatus.NotSystemAdmin, adminServiceSession.ViewPurchaseHistoryByUser(userNameToView1).Status); Assert.AreEqual((int)ViewPurchaseHistoryStatus.NotSystemAdmin, adminServiceSession.ViewPurchaseHistoryByStore(storeNameToView2).Status); }
public void SelfTerminationBlockedTest() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)RemoveUserStatus.SelfTermination, adminServiceSession.RemoveUser(adminName).Status); Assert.IsTrue(MarketException.HasErrorRaised()); }
public void NoUserToRemoveFoundTest() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)RemoveUserStatus.NoUserFound, adminServiceSession.RemoveUser(noUserName).Status); Assert.IsTrue(MarketException.HasErrorRaised()); }
public void NotSystemAdminTest() { userServiceSession.EnterSystem(); userServiceSession.SignIn("Arik2", "123"); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)RemoveUserStatus.NotSystemAdmin, adminServiceSession.RemoveUser(toRemoveUserNameSoleOwner).Status); }
public void NoUserNameTest() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)ViewPurchaseHistoryStatus.NoUserFound, adminServiceSession.ViewPurchaseHistoryByUser(noUserName).Status); Assert.IsTrue(MarketException.HasErrorRaised()); }
private static SystemAdmin AddSystemAdminToken(string email, string token) { using (var service = new SystemAdminService()) { var sysAdmin = service.GetWhere(SystemAdminService.EmailCol == email).FirstOrDefault(); if (sysAdmin != null) { using (var tokenService = new SystemAdminTokenService()) { var storedToken = tokenService.GetWhere(SystemAdminTokenService.SystemAdminCodeCol == sysAdmin.Code).FirstOrDefault(); if (storedToken == null) { tokenService.Create(new SystemAdminToken(sysAdmin, token)); } else { storedToken.Token = token; storedToken.Expires = DateTime.Now.ToUniversalTime().AddHours(Config.TokenDuration); tokenService.Update(storedToken); } } } return(sysAdmin); } }
public LoginModel(string email) { pharmacyList = new List <Pharmacy>(); using (var service = new PharmacistService()) { var pharmacist = service.GetWhere(PharmacistService.EmailCol == email).FirstOrDefault(); if (pharmacist != null) { var jobs = pharmacist.Jobs; foreach (var job in jobs) { var pharmacy = job.Pharmacy; pharmacyList.Add(job.Pharmacy); } } } using (var service = new SystemAdminService()) { var admin = service.GetWhere(SystemAdminService.EmailCol == email).FirstOrDefault(); if (admin != null) { pharmacyList.Add(new Pharmacy(-1, "System Admin", "000-000-0000", "no address")); } } }
public static byte[] HashUserText(SystemAdmin admin, string text) { using (var service = new SystemAdminService()) { var salt = service.Get(admin.Code).PasswordSalt; return(GenerateSaltedHash(Encoding.ASCII.GetBytes(text), salt)); } }
public JsonResult GetSingleAdmin(int id) { using (var service = new SystemAdminService()) { var result = service.Get(id); return(Json(result)); } }
public void StoreClosedUponUserRemovalTest() { ToSignIn(adminName, adminPass); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)RemoveUserStatus.Success, adminServiceSession.RemoveUser(soleOwnerName).Status); storeShoppingService = marketSession.GetStoreShoppingService(ref userServiceSession); Assert.AreEqual((int)StoreEnum.StoreNotExists, storeShoppingService.AddProductToCart("Y", "BOX", 3).Status); }
public void RemoveCategorySuccess() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); MarketAnswer ans = adminServiceSession.RemoveCategory("WanderlandItems"); Assert.AreEqual((int)EditCategoryStatus.Success, ans.Status); }
public void AddCategorySuccess() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); MarketAnswer ans = adminServiceSession.AddCategory("Good item"); Assert.AreEqual((int)EditCategoryStatus.Success, ans.Status); }
public void RemoveCategoryWhenCategoryNotExists() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); MarketAnswer ans = adminServiceSession.RemoveCategory("bad item"); Assert.AreEqual((int)EditCategoryStatus.CategoryNotExistsInSystem, ans.Status); }
public void NotSystemAdminTest() { userServiceSession.EnterSystem(); Assert.AreEqual((int)SignInStatus.Success, userServiceSession.SignIn("Arik2", "123").Status); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)ViewPurchaseHistoryStatus.NotSystemAdmin, adminServiceSession.ViewPurchaseHistoryByUser(userNameToView1).Status); Assert.AreEqual((int)ViewPurchaseHistoryStatus.NotSystemAdmin, adminServiceSession.ViewPurchaseHistoryByStore(storeNameToView2).Status); }
public void AddCategoryWhenCategoryAlreadyExists() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); MarketAnswer ans = adminServiceSession.AddCategory("WanderlandItems"); Assert.AreEqual((int)EditCategoryStatus.CategoryAlradyExist, ans.Status); }
public void ViewPoliciesTest1() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); MarketAnswer ans = adminServiceSession.ViewPolicies(); Assert.AreEqual((int)ViewPolicyStatus.Success, ans.Status); Assert.AreEqual(1, ans.ReportList.Length); }
public void AddComplexPolicySuccess2() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.CreatePolicy("Product", "Hash", "Quantity <=", "10", "0").Status); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.CreatePolicy("Product", "Hash", "Username ="******"Ricky", "0").Status); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.CreatePolicy("Product", "Hash", "AND", "0", "1").Status); Assert.AreEqual((int)EditPolicyStatus.Success, adminServiceSession.SavePolicy().Status); }
public void SignUpWithDeletedUserDataTest() { ToSignIn(adminName, adminPass); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); adminServiceSession.RemoveUser(soleOwnerName); deletedUserSession2 = (UserService)marketSession.GetUserService(); deletedUserSession2.EnterSystem(); Assert.AreEqual((int)SignUpStatus.Success, deletedUserSession2.SignUp(soleOwnerName, "no-where", soleOwnerPass, "12345678").Status); }
public static byte[] HashPassword(SystemAdmin admin, string password) { using (var service = new SystemAdminService()) { var salt = CreateSalt(32); admin.PasswordSalt = salt; admin.PasswordHash = GenerateSaltedHash(Encoding.ASCII.GetBytes(password), admin.PasswordSalt); service.Update(admin); return(admin.PasswordHash); } }
public void MarketBuilder() { MarketDB.Instance.InsertByForce(); marketSession = MarketYard.Instance; userServiceSession = (UserService)marketSession.GetUserService(); userAdminHarmony = null; adminServiceSession = null; deletedUserSession = null; deletedUserSession2 = null; storeShoppingService = null; orderService = null; }
public void RemovePolicy1() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); AddGlobalPolicy(); AddProductPolicy(); MarketAnswer ans = adminServiceSession.RemovePolicy("Global", null); Assert.AreEqual((int)EditPolicyStatus.Success, ans.Status); ans = adminServiceSession.ViewPolicies(); Assert.AreEqual(2, ans.ReportList.Length); }
public void CantLoginToDeletedUserTest() { deletedUserSession = (UserService)marketSession.GetUserService(); deletedUserSession.EnterSystem(); deletedUserSession.SignUp("DeleteMe", "no-where", "123", "12345678"); ToSignIn(adminName, adminPass); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); adminServiceSession.RemoveUser("DeleteMe"); deletedUserSession2 = (UserService)marketSession.GetUserService(); deletedUserSession2.EnterSystem(); Assert.AreEqual((int)SignInStatus.NoUserFound, deletedUserSession2.SignIn("DeleteMe", "123").Status); }
public JsonResult GetAllAdmins() { using (var service = new SystemAdminService()) { List <SystemAdminModel> result = new List <SystemAdminModel>(); var admins = service.GetAll(); foreach (var admin in admins) { result.Add(new SystemAdminModel(admin)); } return(Json(result)); } }
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) { if (FormsAuthentication.CookiesSupported == true) { if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { try { //get the username FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value); JavaScriptSerializer serializer = new JavaScriptSerializer(); PPOKPrincipalSerializeModel serializeModel = serializer.Deserialize <PPOKPrincipalSerializeModel>(authTicket.UserData); PPOKPrincipal newUser = new PPOKPrincipal(serializeModel.Email); switch (serializeModel.Type) { case AccountTypes.Pharmacist: case AccountTypes.Admin: using (var service = new PharmacistService()) { newUser = new PPOKPrincipal(service.Get(serializeModel.Code), serializeModel.Pharmacy.Code); } break; case AccountTypes.Patient: using (var service = new PatientService()) { newUser = new PPOKPrincipal(service.Get(serializeModel.Code)); } break; case AccountTypes.System: using (var service = new SystemAdminService()) { newUser = new PPOKPrincipal(service.Get(serializeModel.Code)); } break; } HttpContext.Current.User = newUser; } catch (Exception ex) { Console.WriteLine(ex.Message); //somehting went wrong } } } }
public void PurchaseHistoryOfStoreTest() { DoSignInToAdmin(); adminServiceSession = (SystemAdminService)marketSession.GetSystemAdminService(userServiceSession); string[] expectedHistory = { new PurchaseHistory(userNameToView1, "INT Potion", storeNameToView2, "Lottery", 2, 8.0, "29/12/2018").ToString(), new PurchaseHistory(userNameToView1, "Mana Potion", storeNameToView2, "Lottery", 3, 12.0, "29/12/2018").ToString(), new PurchaseHistory(userNameToView2, "STR Potion", storeNameToView2, "Immediate", 1, 4.0, "29/12/2018").ToString(), }; Assert.AreEqual((int)ViewPurchaseHistoryStatus.Success, adminServiceSession.ViewPurchaseHistoryByStore(storeNameToView2).Status); Assert.IsTrue(adminServiceSession.ViewPurchaseHistoryByStore(storeNameToView2).ReportList.SequenceEqual(expectedHistory)); Assert.IsFalse(MarketException.HasErrorRaised()); }
public ActionResult AddAdmin(string FirstName, string LastName, string Email, string Phone) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var emailService = new EmailService()) using (var service = new SystemAdminService()) { service.Create(new SystemAdmin(FirstName, LastName, Email, Phone, new byte[0], new byte[0])); emailService.SendEmail(Email, newAccountEmailSubject, newAccountEmailBody); return(View("Admins")); } }
public SysAdminValiController(SystemAdminService systemAdminService) { this._systemAdminService = systemAdminService; }