public int CreateUserNotifyTo(UserNotifyTo obj) { try { #region Parameters var parameters = new List <OracleParameter> { new OracleParameter { ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue }, new OracleParameter { ParameterName = "v_ins_id", OracleDbType = OracleDbType.Int32, Value = obj.UserNotifyId }, new OracleParameter { ParameterName = "v_role_id", OracleDbType = OracleDbType.Int32, Value = obj.Role.Id } }; #endregion db.ExecuteStoredProc("pk_infra.fn_create_userinstructto", parameters); var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString()); return(result); } catch (Exception ex) { return(-1); } }
public IActionResult Create(UserNotifyDto model) { var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext); var permission = partnerActivity.GetPartAct("UserNotify.Create", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (model.Id > 0) { toastNotification.AddErrorToastMessage("تم الحفظ مسبقا", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (ModelState.IsValid) { var created = new UserNotify(); created.Content = model.Content; created.Subject = model.Subject; created.ExpireOn = model.ExpireOn; created.Priority.Id = model.PriorityId; created.CreatedBy.Id = partnerManager.GetCurrentUserId(this.HttpContext); created.CreatedBy.Account = partnerManager.GetCurrentUserAccount(this.HttpContext); if (!string.IsNullOrEmpty(model.SelectedRoles)) { var roles = model.SelectedRoles.Split(','); foreach (string item in roles) { var notifyTo = new UserNotifyTo(); notifyTo.Role.Id = int.Parse(item); created.NotifyToList.Add(notifyTo); } } var result = new UserNotifyRepo(db).Create(created); if (result.AffectedCount > 0) { toastNotification.AddSuccessToastMessage("تم اضافة التعميم بنجاح", new ToastrOptions { Title = "" }); ModelState.Clear(); model.Id = result.AffectedCount; } } model.Priorities = new CommonCodeRepo(db).GetCodesByType("priority"); model.Roles = new RoleRepo(db, partnerActivity).GetAuthorizedRoles("UserNotify.Create", currentRoleId); return(View(model)); }
private List <UserNotifyTo> GetUserNotifyToList(int id) { if (id <= 0) { return(null); } var WhereClause = new StringBuilder(); var parameters = new List <OracleParameter>(); var parm = new OracleParameter { ParameterName = "InsId", OracleDbType = OracleDbType.Int32, Value = id }; parameters.Add(parm); var strSqlStatment = new StringBuilder(); strSqlStatment.Append($"select t.to_id, t.ins_id, t.role_id,r.rolename from users_instruct_to t, approle r where t.role_id = r.roleid and t.ins_id = :InsId "); var masterDataTable = this.db.GetData(strSqlStatment.ToString(), parameters); if (masterDataTable == null) { return(null); } if (masterDataTable.Rows.Count == 0) { return(null); } var results = new List <UserNotifyTo>(); foreach (DataRow row in masterDataTable.Rows) { var obj = new UserNotifyTo(); obj.Id = row["to_id"] == DBNull.Value ? -1 : int.Parse(row["to_id"].ToString()); obj.UserNotifyId = row["ins_id"] == DBNull.Value ? -1 : int.Parse(row["ins_id"].ToString()); obj.Role.Id = row["role_id"] == DBNull.Value ? -1 : int.Parse(row["role_id"].ToString()); obj.Role.Name = row["rolename"] == DBNull.Value ? string.Empty : row["rolename"].ToString(); results.Add(obj); } return(results); }