public ActionResult Create(AffiliateModel model, bool continueEditing) { if (ModelState.IsValid) { var affiliate = new Affiliate(); affiliate.Active = model.Active; affiliate.Address = model.Address.ToEntity(); affiliate.Address.CreatedOnUtc = DateTime.UtcNow; //some validation if (affiliate.Address.CountryId == 0) { affiliate.Address.CountryId = null; } if (affiliate.Address.StateProvinceId == 0) { affiliate.Address.StateProvinceId = null; } _affiliateService.InsertAffiliate(affiliate); NotifySuccess(T("Admin.Affiliates.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = affiliate.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form PrepareAffiliateModel(model, null, true); return(View(model)); }
public ActionResult Create(AffiliateModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var affiliate = new Affiliate(); affiliate.Active = model.Active; affiliate.AdminComment = model.AdminComment; affiliate.Address = model.Address.ToEntity(); affiliate.Address.CreatedOnUtc = DateTime.UtcNow; //some validation if (affiliate.Address.CountryId == 0) { affiliate.Address.CountryId = null; } if (affiliate.Address.StateProvinceId == 0) { affiliate.Address.StateProvinceId = null; } _affiliateService.InsertAffiliate(affiliate); SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = affiliate.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form PrepareAffiliateModel(model, null, true); return(View(model)); }
public ActionResult Create(AffiliateModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var affiliate = new 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.Id = 1; affiliate.Address._id = ObjectId.GenerateNewId().ToString(); affiliate.Address.CreatedOnUtc = DateTime.UtcNow; //some validation _affiliateService.InsertAffiliate(affiliate); SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = affiliate.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form PrepareAffiliateModel(model, null, true); return(View(model)); }
public virtual IActionResult Create(AffiliateModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var affiliate = new Affiliate { Active = model.Active, AdminComment = model.AdminComment }; //validate friendly URL name var friendlyUrlName = affiliate.ValidateFriendlyUrlName(model.FriendlyUrlName); affiliate.FriendlyUrlName = friendlyUrlName; affiliate.Address = model.Address.ToEntity(); affiliate.Address.CreatedOnUtc = DateTime.UtcNow; //some validation if (affiliate.Address.CountryId == 0) { affiliate.Address.CountryId = null; } if (affiliate.Address.StateProvinceId == 0) { affiliate.Address.StateProvinceId = null; } _affiliateService.InsertAffiliate(affiliate); //activity log _customerActivityService.InsertActivity("AddNewAffiliate", string.Format(_localizationService.GetResource("ActivityLog.AddNewAffiliate"), affiliate.Id), affiliate); SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = affiliate.Id }) : RedirectToAction("List")); } //prepare model model = _affiliateModelFactory.PrepareAffiliateModel(model, null, true); //if we got this far, something failed, redisplay form return(View(model)); }
public virtual Affiliate InsertAffiliateModel(AffiliateModel model) { var affiliate = new 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.CreatedOnUtc = DateTime.UtcNow; //some validation _affiliateService.InsertAffiliate(affiliate); return(affiliate); }
public virtual async Task <Affiliate> InsertAffiliateModel(AffiliateModel model) { var affiliate = new 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.CreatedOnUtc = DateTime.UtcNow; //some validation await _affiliateService.InsertAffiliate(affiliate); return(affiliate); }
public async Task InsertAffiliate_NullParameter_ThrwoException() { await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await _affiliateService.InsertAffiliate(null), "affiliate"); }
/// <summary> /// Inserts an affiliate /// </summary> /// <param name="affiliate">Affiliate</param> public void InsertAffiliate(Affiliate affiliate) { _affiliateService.InsertAffiliate(affiliate); }