public IActionResult AddShopManager(string ManagerName, string ShopId, bool manageProducts = false, bool manageShopState = false, bool managePolicies = false, bool appointManagers = false) { try { Guid OwnerId = _serviceFacade.GetUserGuid(ManagerName); //need to adress the empty guid thingy ICollection <bool> privileges = new List <bool> { manageProducts, manageShopState, managePolicies, appointManagers }; _serviceFacade.AddShopManager(new Guid(HttpContext.Session.Id), new Guid(ShopId), OwnerId, privileges.ToList()); return(RedirectToAction("Manage", "Seller", new { ShopId })); } catch (NoPrivilegesException) { var redirect = this.Url.Action("Index", "Seller"); var message = new UserMessage(redirect, "You haven't sufficient priviliges. Cannot complete the request."); return(View("UserMessage", message)); } catch (BrokenConstraintException) { var redirect = this.Url.Action("Index", "Seller"); var message = new UserMessage(redirect, "User is already a manager."); return(View("UserMessage", message)); } catch (GeneralServerError) { var redirect = this.Url.Action("Index", "Seller"); var message = new UserMessage(redirect, "An error has occured. Please refresh and try again."); return(View("UserMessage", message)); } catch (DatabaseConnectionTimeoutException) { var redirect = this.Url.Action("Index", "Seller"); var message = new UserMessage(redirect, "An error has occured. Please refresh and try again. (Database connection lost)."); return(View("UserMessage", message)); } }
public bool AddShopManager(Guid userGuid, Guid shopGuid, Guid newManagaerGuid, List <bool> privileges) { return(_serviceFacade.AddShopManager(userGuid, shopGuid, newManagaerGuid, privileges)); }