public virtual void UpdateAssignUser(StoreUserAssign storeUserAssign) { if (storeUserAssign == null) { throw new ArgumentNullException(nameof(storeUserAssign)); } _storeUserAssignRepository.Update(storeUserAssign); }
public async Task InsertAssignUser(StoreUserAssign storeUserAssign) { if (storeUserAssign == null) { throw new ArgumentNullException(nameof(storeUserAssign)); } await _storeUserAssignRepository.InsertAsync(storeUserAssign); }
public virtual void DeleteAssignUser(StoreUserAssign storeUserAssign) { if (storeUserAssign == null) { throw new ArgumentNullException(nameof(storeUserAssign)); } _storeUserAssignStoresRepository.Delete(storeUserAssign.StoreUserAssignStore); _storeUserAssignRepository.Delete(storeUserAssign); }
public async Task <IActionResult> AddAssignUser(AssignUserModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOutletManagement)) { return(AccessDeniedView()); } //validate store if (model.SelectedUserStoreId == 0) { ModelState.AddModelError(string.Empty, "Store is required"); _notificationService.ErrorNotification("Store is required"); } try { //Store StoreUserAssign storeUserAssign = new StoreUserAssign { StoreId = model.SelectedUserStoreId, StoreUserAssignStore = new List <StoreUserAssignStores>() }; //Add user foreach (var user in model.SelectedUserIds) { StoreUserAssignStores storeUserAssignStores = new StoreUserAssignStores { StoreUserAssignId = storeUserAssign.Id, UserId = user, }; storeUserAssign.StoreUserAssignStore.Add(storeUserAssignStores); } await _outletManagementService.InsertAssignUser(storeUserAssign); return(new NullJsonResult()); } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); _notificationService.ErrorNotification(e.Message); return(Json(e.Message)); } }
public async Task <AssignUserModel> PrepareAssignUserModel(AssignUserModel model, StoreUserAssign storeUserAssign) { if (storeUserAssign != null) { model = model ?? new AssignUserModel(); model.Id = storeUserAssign.Id; model.SelectedUserStoreId = storeUserAssign.StoreId; model.SelectedUserIds = storeUserAssign.StoreUserAssignStore.Select(map => map.UserId).ToList(); model.CreatedOn = _dateTimeHelper.ConvertToUserTime(storeUserAssign.CreatedOnUtc, DateTimeKind.Utc); model.LastActivityDate = _dateTimeHelper.ConvertToUserTime(storeUserAssign.ModifiedOnUtc.GetValueOrDefault(DateTime.UtcNow), DateTimeKind.Utc); } //store var stores = await _storeService.GetStores(); model.AvailableUserStores = stores.Select(store => new SelectListItem { Text = store.P_BranchNo.ToString() + " - " + store.P_Name, Value = store.P_BranchNo.ToString() }).ToList(); //users var users = await _userService.GetUsersAsync(); model.AvailableUsers = users.Select(user => new SelectListItem { Text = user.Username, Value = user.Id.ToString() }).ToList(); return(await Task.FromResult(model)); }