コード例 #1
0
        public IActionResult AddDetail(int id)
        {
            var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = _partActRepo.GetPartAct("PartnerActivity.Detail.Create", currentRoleId);

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

            if (masterModel == null)
            {
                return(null);
            }
            var toRoles = new RoleRepo(db, _partActRepo).GetRoles();
            var model   = new CreatePartnerActivityDetailDto
            {
                ParentId     = masterModel.Id,
                ActivityId   = masterModel.Activity.Id,
                ActivityName = masterModel.Activity.Name,
                FromRoleId   = masterModel.FromRole.Id,
                FromRoleName = masterModel.FromRole.Name,
                ToRoles      = toRoles
            };

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

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


                var originObject = new PartnerActivityDetail();
                originObject.Id                   = model.Id;
                originObject.ParentId             = model.ParentId;
                originObject.ToRole.Id            = model.ToRoleId;
                originObject.CheckBalanceRequired = model.CheckBalanceRequired;
                originObject.MinValue             = model.MinValue;
                originObject.MaxValue             = model.MaxValue;
                originObject.TaxPercent           = model.TaxPercent;
                originObject.BonusPercent         = model.BonusPercent;
                originObject.BonusTaxPercent      = model.BonusTaxPercent;
                originObject.FixedFactor          = model.FixedFactor;
                originObject.CreatedBy.Id         = _PartnerManager.GetCurrentUserId(this.HttpContext);
                var result = _partActRepo.UpdateDetail(originObject);
                if (result.Success)
                {
                    var audit = new DataAudit();
                    audit.Activity.Id    = "PartnerActivity.Detail.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       = originObject.ToString();
                    var auditResult = _auditing.Create(audit);
                    if (!auditResult.Success)
                    {
                        _logger.LogError($"Edit Partner Activity Detail no[{originObject.Id}] , Error was {auditResult.Error}");
                    }
                }
                return(RedirectToAction("Detail", new { id = model.ParentId }));
            }
            model.ToRoles = new RoleRepo(db, _partActRepo).GetRoles();
            return(View(model));
        }
コード例 #3
0
        public IActionResult EditDetail(int id, int parentId)
        {
            var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = _partActRepo.GetPartAct("PartnerActivity.Detail.Edit", currentRoleId);

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

            var model = _partActRepo.GetDetail(id, parentId, true);

            if (model == null)
            {
                return(null);
            }
            var toRoles = new RoleRepo(db, _partActRepo).GetRoles();

            var viewModel = new CreatePartnerActivityDetailDto
            {
                ParentId             = model.Parent.Id,
                ActivityId           = model.Parent.Activity.Id,
                ActivityName         = model.Parent.Activity.Name,
                ToRoleId             = model.ToRole.Id,
                ToRole               = model.ToRole,
                CheckBalanceRequired = model.CheckBalanceRequired,
                MinValue             = model.MinValue,
                MaxValue             = model.MaxValue,
                TaxPercent           = model.TaxPercent,
                BonusPercent         = model.BonusPercent,
                BonusTaxPercent      = model.BonusTaxPercent,
                FixedFactor          = model.FixedFactor,
                ToRoles              = toRoles
            };

            return(View(viewModel));
        }
コード例 #4
0
        public IActionResult AddDetail(CreatePartnerActivityDetailDto model)
        {
            if (ModelState.IsValid)
            {
                var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext);
                var permission    = _partActRepo.GetPartAct("PartnerActivity.Detail.Create", currentRoleId);
                if (permission == null)
                {
                    toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions
                    {
                        Title = ""
                    });
                    return(Redirect(Request.Headers["Referer"].ToString()));
                }

                var masterModel = _partActRepo.GetPartAct(model.ParentId);
                if (masterModel == null)
                {
                    return(null);
                }
                var originObject = new PartnerActivityDetail();
                originObject.ParentId             = model.ParentId;
                originObject.ToRole.Id            = model.ToRoleId;
                originObject.CheckBalanceRequired = model.CheckBalanceRequired;
                originObject.MinValue             = model.MinValue;
                originObject.MaxValue             = model.MaxValue;
                originObject.TaxPercent           = model.TaxPercent;
                originObject.BonusPercent         = model.BonusPercent;
                originObject.BonusTaxPercent      = model.BonusTaxPercent;
                originObject.FixedFactor          = model.FixedFactor;
                originObject.CreatedBy.Id         = _PartnerManager.GetCurrentUserId(this.HttpContext);
                var result = _partActRepo.CreateDetail(originObject);
                if (result.Success)
                {
                    return(RedirectToAction("Detail", new { id = model.ParentId }));
                }
            }
            model.ToRoles = new RoleRepo(db, _partActRepo).GetRoles();
            return(View(model));
        }