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));
        }
        public IActionResult Create()
        {
            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()));
            }
            var model = new UserNotifyDto();

            model.Priorities = new CommonCodeRepo(db).GetCodesByType("priority");
            model.Roles      = new RoleRepo(db, partnerActivity).GetAuthorizedRoles("UserNotify.Create", currentRoleId);
            var expiredAfter = Convert.ToInt32(new AppGlobalSettingsRepo(db).GetSingle("UserInstructExpireDays").SettingValue);

            model.ExpireOn = DateTime.Today.AddDays(expiredAfter);
            return(View(model));
        }