Exemple #1
0
        public ActionResult Edit(AffiliateModel model, bool continueEditing)
        {
            var affiliate = _affiliateService.GetAffiliateById(model.Id);

            if (affiliate == null || affiliate.Deleted)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                affiliate.Active  = model.Active;
                affiliate.Address = model.Address.ToEntity(affiliate.Address);
                //some validation
                if (affiliate.Address.CountryId == 0)
                {
                    affiliate.Address.CountryId = null;
                }
                if (affiliate.Address.StateProvinceId == 0)
                {
                    affiliate.Address.StateProvinceId = null;
                }
                _affiliateService.UpdateAffiliate(affiliate);

                NotifySuccess(T("Admin.Affiliates.Updated"));
                return(continueEditing ? RedirectToAction("Edit", affiliate.Id) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            PrepareAffiliateModel(model, affiliate, true);
            return(View(model));
        }
Exemple #2
0
        public virtual IActionResult Edit(AffiliateModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            //try to get an affiliate with the specified id
            var affiliate = _affiliateService.GetAffiliateById(model.Id);

            if (affiliate == null || affiliate.Deleted)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                affiliate = model.ToEntity(affiliate);

                //validate friendly URL name
                var friendlyUrlName = affiliate.ValidateFriendlyUrlName(model.FriendlyUrlName);
                affiliate.FriendlyUrlName = friendlyUrlName;

                affiliate.Address = model.Address.ToEntity(affiliate.Address);

                //some validation
                if (affiliate.Address.CountryId == 0)
                {
                    affiliate.Address.CountryId = null;
                }
                if (affiliate.Address.StateProvinceId == 0)
                {
                    affiliate.Address.StateProvinceId = null;
                }

                _affiliateService.UpdateAffiliate(affiliate);

                //activity log
                _customerActivityService.InsertActivity("EditAffiliate",
                                                        string.Format(_localizationService.GetResource("ActivityLog.EditAffiliate"), affiliate.Id), affiliate);

                SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = affiliate.Id }));
            }

            //prepare model
            model = _affiliateModelFactory.PrepareAffiliateModel(model, affiliate, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #3
0
        public Affiliate UpdateAffiliate([FromBody] Affiliate affiliate)
        {
            UpdateAuditData(affiliate);

            _affiliateService.UpdateAffiliate(ref affiliate);

            return(affiliate);
        }
Exemple #4
0
        public virtual Affiliate UpdateAffiliateModel(AffiliateModel model, Affiliate affiliate)
        {
            affiliate.Active       = model.Active;
            affiliate.AdminComment = model.AdminComment;
            //validate friendly URL name
            var friendlyUrlName = affiliate.ValidateFriendlyUrlName(model.FriendlyUrlName);

            affiliate.FriendlyUrlName = friendlyUrlName;
            affiliate.Address         = model.Address.ToEntity(affiliate.Address);
            _affiliateService.UpdateAffiliate(affiliate);
            return(affiliate);
        }
        public virtual async Task <Affiliate> UpdateAffiliateModel(AffiliateModel model, Affiliate affiliate)
        {
            affiliate.Active       = model.Active;
            affiliate.AdminComment = model.AdminComment;
            //validate friendly URL name
            var friendlyUrlName = await affiliate.ValidateFriendlyUrlName(_affiliateService, _seoSettings, model.FriendlyUrlName);

            affiliate.FriendlyUrlName = friendlyUrlName;
            affiliate.Address         = model.Address.ToEntity(affiliate.Address);
            await _affiliateService.UpdateAffiliate(affiliate);

            return(affiliate);
        }
Exemple #6
0
        public ActionResult Edit(AffiliateModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            var affiliate = _affiliateService.GetAffiliateById(model.Id);

            if (affiliate == null || affiliate.Deleted)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                affiliate.Active   = model.Active;
                affiliate.NickName = model.NickName;
                affiliate.Address  = model.Address.ToEntity(affiliate.Address);
                //some validation
                if (affiliate.Address.CountryId == 0)
                {
                    affiliate.Address.CountryId = null;
                }
                if (affiliate.Address.StateProvinceId == 0)
                {
                    affiliate.Address.StateProvinceId = null;
                }
                _affiliateService.UpdateAffiliate(affiliate);

                SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", affiliate.Id));
                }
                else
                {
                    return(RedirectToAction("List"));
                }
            }

            //If we got this far, something failed, redisplay form
            PrepareAffiliateModel(model, affiliate, true);
            return(View(model));
        }
        public IActionResult Edit(AffiliateModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            var affiliate = _affiliateService.GetAffiliateById(model.Id);

            if (affiliate == null || affiliate.Deleted)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                affiliate.Active       = model.Active;
                affiliate.AdminComment = model.AdminComment;
                //validate friendly URL name
                var friendlyUrlName = affiliate.ValidateFriendlyUrlName(model.FriendlyUrlName);
                affiliate.FriendlyUrlName = friendlyUrlName;
                affiliate.Address         = model.Address.ToEntity(affiliate.Address);
                _affiliateService.UpdateAffiliate(affiliate);

                SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = affiliate.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            PrepareAffiliateModel(model, affiliate, true);
            return(View(model));
        }
Exemple #8
0
 public async Task UpdateAffiliate_NullParameter_ThrwoException()
 {
     await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await _affiliateService.UpdateAffiliate(null), "affiliate");
 }
 /// <summary>
 /// Updates the affiliate
 /// </summary>
 /// <param name="affiliate">Affiliate</param>
 public void UpdateAffiliate(Affiliate affiliate)
 {
     _affiliateService.UpdateAffiliate(affiliate);
 }