/// <summary> /// Delete a vendor /// </summary> /// <param name="vendor">Vendor</param> public virtual void DeleteVendor(Vendor vendor) { if (vendor == null) throw new ArgumentNullException("vendor"); vendor.Deleted = true; UpdateVendor(vendor); }
public void Can_save_and_load_vendor() { var vendor = new Vendor { Name = "Name 1", Email = "Email 1", Description = "Description 1", AdminComment = "AdminComment 1", Active = true, Deleted = true, }; var fromDb = SaveAndLoadEntity(vendor); fromDb.ShouldNotBeNull(); fromDb.Name.ShouldEqual("Name 1"); fromDb.Email.ShouldEqual("Email 1"); fromDb.Description.ShouldEqual("Description 1"); fromDb.AdminComment.ShouldEqual("AdminComment 1"); fromDb.Active.ShouldEqual(true); fromDb.Deleted.ShouldEqual(true); }
public ActionResult Create(VendorModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors)) return AccessDeniedView(); if (ModelState.IsValid) { var vendor = new Vendor(); vendor.Name = model.Name; vendor.Email = model.Email; vendor.Description = model.Description; vendor.AdminComment = model.AdminComment; vendor.Active = model.Active; _vendorService.InsertVendor(vendor); SuccessNotification(_localizationService.GetResource("Admin.Vendors.Added")); return continueEditing ? RedirectToAction("Edit", new { id = vendor.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form PrepareVendorModel(model, null, true); return View(model); }
/// <summary> /// Sends an order placed notification to a vendor /// </summary> /// <param name="order">Order instance</param> /// <param name="vendor">Vendor instance</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public virtual int SendOrderPlacedVendorNotification(Order order, Vendor vendor, int languageId) { if (order == null) throw new ArgumentNullException("order"); if (vendor == null) throw new ArgumentNullException("vendor"); var store = _storeService.GetStoreById(order.StoreId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("OrderPlaced.VendorNotification", languageId, store.Id); if (messageTemplate == null) return 0; //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store); _messageTokenProvider.AddOrderTokens(tokens, order, languageId); _messageTokenProvider.AddCustomerTokens(tokens, order.Customer); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var toEmail = vendor.Email; var toName = vendor.Name; return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
/// <summary> /// Inserts a vendor /// </summary> /// <param name="vendor">Vendor</param> public virtual void InsertVendor(Vendor vendor) { if (vendor == null) throw new ArgumentNullException("vendor"); _vendorRepository.Insert(vendor); //event notification _eventPublisher.EntityInserted(vendor); }
protected void PrepareVendorModel(VendorModel model, Vendor vendor, bool excludeProperties) { if (model == null) throw new ArgumentNullException("model"); if (vendor != null) { model.Id = vendor.Id; model.AssociatedCustomerEmails = _customerService .GetAllCustomers(vendorId: vendor.Id) .Select(c => c.Email) .ToList(); if (!excludeProperties) { model.Name = vendor.Name; model.Email = vendor.Email; model.Description = vendor.Description; model.AdminComment = vendor.AdminComment; model.Active = vendor.Active; } } }