public ActionResult ClerkEdit(EditClerkModel WebData) { try { String MerchantID = GetFromMerchantIDCookie(); if (ModelState.IsValid) { ICLerkService ClerkServiceInstance = new ClerkService(); // I tried to put this into an update method, // but the compiler couldn't find the methods ClerkServiceInstance.DeleteClerk(Convert.ToInt32(WebData.DatabaseID)); AddClerkModel ToAdd = new AddClerkModel(); ToAdd.ClerkID = WebData.ClerkID; ToAdd.ClerkName = WebData.ClerkName; ToAdd.ClerkPassword = WebData.Password; ClerkServiceInstance.AddClerk(MerchantID, ToAdd); ViewData["Message"] = "Update Successful"; } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionHandler(Ex, "Clerk Edit", Request.Form)); Log.BadData(Request.UserHostAddress, Request.Url.ToString(), Request.Form); } return(View(WebData)); }
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); }
public ActionResult ClerkAdd(AddClerkModel WebData) { try { String MerchantID = GetFromMerchantIDCookie(); if (ModelState.IsValid) { ICLerkService ClerkServiceInstance = new ClerkService(); if (ClerkServiceInstance.AddClerk(MerchantID, WebData)) { return(RedirectToAction("ClerkManagement")); } } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionHandler(Ex, "Add Clerk", Request.Form)); Log.BadData(Request.UserHostAddress, Request.Url.ToString(), Request.Form); } // If we got this far, something failed, redisplay form return(View(WebData)); }
public ActionResult SuggestValues(SuggestClerkModel SuggestData) { AddClerkModel WebData = new AddClerkModel(); WebData.ClerkID = SuggestData.ClerkID; WebData.ClerkName = SuggestData.ClerkName; try { if (ModelState.IsValid) { ICLerkService ClerkServiceInstance = new ClerkService(); WebData.ClerkPassword = ClerkServiceInstance.SuggestClerkPassword(); } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionHandler(Ex, "Suggest Clerk password", Request.Form)); Log.BadData(Request.UserHostAddress, Request.Url.ToString(), Request.Form); } return(View(WebData)); }