public IActionResult Edit(CreatePartnerActivity2Dto model)
        {
            if (ModelState.IsValid)
            {
                var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext);
                var permission    = _partActRepo.GetPartAct("PartnerActivity.Edit", currentRoleId);
                if (permission == null)
                {
                    toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions
                    {
                        Title = ""
                    });
                    return(Redirect(Request.Headers["Referer"].ToString()));
                }

                var old = _partActRepo.GetPartAct(model.Id);
                if (old == null)
                {
                    return(View(model));
                }

                var pAct = new PartnerActivity();
                pAct.Id                  = model.Id;
                pAct.Activity.Id         = model.ActivityId;
                pAct.FromRole.Id         = model.FromRoleId ?? 0;
                pAct.MaxQueryRows        = model.MaxQueryRowsNo;
                pAct.MaxQueryDuration.Id = model.MaxQueryDurationId;
                pAct.Scope.Id            = model.ScopeId;
                pAct.OnlyPartnerChildren = model.OnlyPartnerChildren;
                pAct.LastEditOn          = DateTime.Now;
                var result = _partActRepo.Edit(pAct);
                if (result.Success)
                {
                    var audit = new DataAudit();
                    audit.Activity.Id    = "PartnerActivity.Edit";
                    audit.PartnerId      = _PartnerManager.GetCurrentUserId(this.HttpContext);
                    audit.PartnerAccount = _PartnerManager.GetCurrentUserAccount(this.HttpContext);
                    audit.Action.Id      = "Update";
                    audit.Success        = true;
                    audit.OldValue       = old.ToString();
                    audit.NewValue       = pAct.ToString();
                    _auditing.Create(audit);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    model.Error = result.Error;
                }
            }
            var fromRoles        = new RoleRepo(db, _partActRepo).GetRoles();
            var activities       = new ActivityRepo(db, _PartnerManager).GetActivities();
            var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration");
            var scopes           = new CommonCodeRepo(db).GetCodesByType("activity.scope");

            model.FromRoles        = fromRoles;
            model.Activities       = activities;
            model.MaxQueryDuration = maxQueryDuration;
            model.Scopes           = scopes;
            return(View(model));
        }
예제 #2
0
        public IActionResult Delete(int id)
        {
            var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = partnerActivity.GetPartAct("MessageTemplate.Delete", currentRoleId);

            if (permission == null)
            {
                toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions {
                    Title = ""
                });
                return(Redirect(Request.Headers["Referer"].ToString()));
            }

            var old = new MessageTemplateRepo(db, partnerManager).GetSingle(id);

            if (old != null)
            {
                var audit = new DataAudit();
                audit.Activity.Id    = "MessageTemplate.Delete";
                audit.PartnerId      = partnerManager.GetCurrentUserId(this.HttpContext);
                audit.PartnerAccount = partnerManager.GetCurrentUserAccount(this.HttpContext);
                audit.Action.Id      = "Delete";
                audit.Success        = true;
                audit.OldValue       = old.ToString();
                auditing.Create(audit);
                new MessageTemplateRepo(db, partnerManager).RemoveMessage(id);
            }
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public IActionResult RemovePV(double pvalue)
        {
            var currentRoleId = _partnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = _partActRepo.GetPartAct("PayemntValues.Remove", currentRoleId);

            if (permission == null)
            {
                _toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية", new ToastrOptions {
                    Title = ""
                });
                return(Redirect(Request.Headers["Referer"].ToString()));
            }

            var removedObj = new PaymentValuesRepo(_db, _partnerManager).GetSingleOrDefault(pvalue);

            if (removedObj == null)
            {
                _toastNotification.AddErrorToastMessage($"المبلغ {pvalue.ToString("N2")} غير موجود", new ToastrOptions {
                    Title = ""
                });
                return(View("PValues"));
            }
            else
            {
                var result = new PaymentValuesRepo(_db, _partnerManager).Remove(pvalue);
                if (result.Success)
                {
                    _toastNotification.AddSuccessToastMessage($"المبلغ {pvalue.ToString("N2")} تم حذفه", new ToastrOptions {
                        Title = ""
                    });
                    var audit = new DataAudit();
                    audit.Activity.Id    = "PayemntValues.Remove";
                    audit.PartnerId      = _partnerManager.GetCurrentUserId(this.HttpContext);
                    audit.PartnerAccount = _partnerManager.GetCurrentUserAccount(this.HttpContext);
                    audit.Action.Id      = "Delete";
                    audit.Success        = true;
                    audit.OldValue       = removedObj.ToString();
                    audit.NewValue       = string.Empty;
                    _auditing.Create(audit);
                }
                PValues();
                return(View("PValues"));
            }
        }