/// <summary> /// Get user payment mode mapping by user id /// </summary> /// <param name="userPaymentModeId"></param> /// <returns></returns> IList<UserPaymentModeMappingDTO> IUserPaymentModeService.GetPaymentModesByUserId(int userId) { //To select agent by agent id UserPaymentModeMappingDTO userPaymentModeDetails = new UserPaymentModeMappingDTO(); IList<UserPaymentModeMappingDTO> lstUserPaymentMapping = (from upmItem in base.UserPaymentModeRepository.GetQuery(). Where(item => item.UPM_UserId == userId) join payItem in base.PaymentModeRepository.GetQuery() on upmItem.UPM_PaymentMode equals payItem.Paymentmode_Id into item from subItem in item.DefaultIfEmpty() select new UserPaymentModeMappingDTO { UPM_Id = upmItem.UPM_Id, UPM_UserId = upmItem.UPM_UserId, UPM_PaymentMode = upmItem.UPM_PaymentMode, PaymentModeName = subItem == null ? string.Empty : subItem.Paymentmode_Name }).ToList(); //return agent details return lstUserPaymentMapping; }
protected void btnSave_Click(object sender, EventArgs e) { if (!CheckSelectedGridRows()) { customValidator.IsValid = false; ucMessageBox.ShowMessage(ErrorMessages.NOPAYMENTMODESELECTED); return; } if (Page.IsValid) { ESalesUnityContainer.Container.Resolve<IUserPaymentModeService>().DeleteUserPaymentModeDetails(GetUserIdByUserName(ddlUsers.SelectedValue)); IList<UserPaymentModeMappingDTO> lstUserPaymentModeMap = new List<UserPaymentModeMappingDTO>(); //Iterate through the Products.Rows property foreach (GridViewRow row in grdUserPaymentMode.Rows) { UserPaymentModeMappingDTO userPaymentModeMapDTO = new UserPaymentModeMappingDTO(); //Access the CheckBox CheckBox chkBox = (CheckBox)row.FindControl("chkSelectPaymentMode"); if (chkBox.Checked) { userPaymentModeMapDTO.UPM_UserId = GetUserIdByUserName(ddlUsers.SelectedValue); userPaymentModeMapDTO.UPM_PaymentMode = Convert.ToInt32(grdUserPaymentMode.DataKeys[row.RowIndex]["PaymentMode_Id"]); userPaymentModeMapDTO.UPM_CreatedBy = base.GetCurrentUserId(); lstUserPaymentModeMap.Add(userPaymentModeMapDTO); } } ESalesUnityContainer.Container.Resolve<IUserPaymentModeService>().SaveUserPaymentModeDetails(lstUserPaymentModeMap); //Shows message box to user ucMessageBox.ShowMessage(Messages.PAYMENTMODEMAPPINGSAVED); GetPaymentModesByUserId(); } }