public void Can_save_and_load_vendor_with_vendorNotes()
        {
            var vendor = new Vendor
            {
                Name = "Name 1",
                Email = "Email 1",
                Description = "Description 1",
                AdminComment = "AdminComment 1",
                PictureId = 1,
                Active = true,
                Deleted = true,
                DisplayOrder = 2,
                MetaKeywords = "Meta keywords",
                MetaDescription = "Meta description",
                MetaTitle = "Meta title",
                PageSize = 4,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "4, 2, 8, 12",
            };

            vendor.VendorNotes.Add
                (
                    new VendorNote
                    {
                        Note = "Note 1",
                        CreatedOnUtc = new DateTime(2010, 01, 01),
                    }
                );
            var fromDb = SaveAndLoadEntity(vendor);
            fromDb.ShouldNotBeNull();

            fromDb.VendorNotes.ShouldNotBeNull();
            fromDb.VendorNotes.Count.ShouldEqual(1);
            fromDb.VendorNotes.First().Note.ShouldEqual("Note 1");
        }
        protected void UpdateLocales(Vendor vendor, VendorModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(vendor,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.Description,
                                                           localized.Description,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);

                //search engine name
                var seName = vendor.ValidateSeName(localized.SeName, localized.Name, false);
                _urlRecordService.SaveSlug(vendor, seName, localized.LanguageId);
            }
        }
        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,
                DisplayOrder = 2,
                MetaKeywords = "Meta keywords",
                MetaDescription = "Meta description",
                MetaTitle = "Meta title",
                PageSize = 4,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "4, 2, 8, 12",
            };

            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);
            fromDb.DisplayOrder.ShouldEqual(2);
            fromDb.MetaKeywords.ShouldEqual("Meta keywords");
            fromDb.MetaDescription.ShouldEqual("Meta description");
            fromDb.MetaTitle.ShouldEqual("Meta title");
            fromDb.PageSize.ShouldEqual(4);
            fromDb.AllowCustomersToSelectPageSize.ShouldEqual(true);
            fromDb.PageSizeOptions.ShouldEqual("4, 2, 8, 12");
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 6
0
        public static void creerMarque(int idMarque)
        {
            //Récupération de la marque dans Distri
            //  ClientWCF.ServiceReference.Service1Client client = new ClientWCF.ServiceReference.Service1Client();
            ServiceReference1.IService1 client = new ServiceReference1.Service1Client("BasicHttpBinding_IService1");
            string marque = client.DemandeMarque(idMarque);
            // string marque = NopService.demandeMarque(idMarque);

            XmlDocument xmlArticle = new XmlDocument();
            xmlArticle.LoadXml(marque);
            XmlNode root = xmlArticle.FirstChild;

            //Création de la marque
            Vendor vendeur = new Vendor();

            vendeur.Id = int.Parse(root["griffe_ID"].InnerText);
            vendeur.Name = root["griffe_Libelle"].InnerText;

            _vendorService.InsertVendor(vendeur);
            _urlRecordService.SaveSlug(vendeur, vendeur.ValidateSeName(vendeur.Name, vendeur.Name, true), 0);
        }
Esempio n. 7
0
        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);
        }
        public ActionResult ApplyVendorSubmit(ApplyVendorModel model, bool captchaValid)
        {
            if (!_vendorSettings.AllowCustomersToApplyForVendorAccount)
                return RedirectToRoute("HomePage");

            if (!_workContext.CurrentCustomer.IsRegistered())
                return new HttpUnauthorizedResult();

            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage && !captchaValid)
            {
                ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha"));
            }

            if (ModelState.IsValid)
            {
                //disabled by default
                var vendor = new Vendor
                {
                    Name = model.Name,
                    Email = model.Email,
                    //some default settings
                    PageSize = 6,
                    AllowCustomersToSelectPageSize = true,
                    PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions
                };
                _vendorService.InsertVendor(vendor);
                //search engine name (the same as vendor name)
                var seName = vendor.ValidateSeName(vendor.Name, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, seName, 0);

                //associate to the current customer
                //but a store owner will have to manually add this customer role to "Vendors" role
                //if he wants to grant access to admin area
                _workContext.CurrentCustomer.VendorId = vendor.Id;
                _customerService.UpdateCustomer(_workContext.CurrentCustomer);

                //notify store owner here (email)
                _workflowMessageService.SendNewVendorAccountApplyStoreOwnerNotification(_workContext.CurrentCustomer,
                    vendor, _localizationSettings.DefaultAdminLanguageId);

                model.DisableFormInput = true;
                model.Result = _localizationService.GetResource("Vendors.ApplyAccount.Submitted");
                return View(model);
            }

            //If we got this far, something failed, redisplay form
            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage;
            return View(model);
        }
Esempio n. 9
0
        public ActionResult ApplyVendorSubmit(ApplyVendorModel model, bool captchaValid, HttpPostedFileBase uploadedFile)
        {
            if (!_vendorSettings.AllowCustomersToApplyForVendorAccount)
                return RedirectToRoute("HomePage");

            if (!_workContext.CurrentCustomer.IsRegistered())
                return new HttpUnauthorizedResult();

            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage && !captchaValid)
            {
                ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService));
            }

            int pictureId = 0;

            if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
            {
                try
                {
                    var contentType = uploadedFile.ContentType;
                    var vendorPictureBinary = uploadedFile.GetPictureBits();
                    var picture = _pictureService.InsertPicture(vendorPictureBinary, contentType, null);

                    if (picture != null)
                        pictureId = picture.Id;
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", _localizationService.GetResource("Vendors.ApplyAccount.Picture.ErrorMessage"));
                }
            }

            if (ModelState.IsValid)
            {
                var description = Core.Html.HtmlHelper.FormatText(model.Description, false, false, true, false, false, false);
                //disabled by default
                var vendor = new Vendor
                {
                    Name = model.Name,
                    Email = model.Email,
                    //some default settings
                    PageSize = 6,
                    AllowCustomersToSelectPageSize = true,
                    PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions,
                    PictureId = pictureId,
                    Description = description
                };
                _vendorService.InsertVendor(vendor);
                //search engine name (the same as vendor name)
                var seName = vendor.ValidateSeName(vendor.Name, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, seName, 0);

                //associate to the current customer
                //but a store owner will have to manually add this customer role to "Vendors" role
                //if he wants to grant access to admin area
                _workContext.CurrentCustomer.VendorId = vendor.Id;
                _customerService.UpdateCustomer(_workContext.CurrentCustomer);

                //update picture seo file name
                UpdatePictureSeoNames(vendor);

                //notify store owner here (email)
                _workflowMessageService.SendNewVendorAccountApplyStoreOwnerNotification(_workContext.CurrentCustomer,
                    vendor, _localizationSettings.DefaultAdminLanguageId);

                model.DisableFormInput = true;
                model.Result = _localizationService.GetResource("Vendors.ApplyAccount.Submitted");
                return View(model);
            }

            //If we got this far, something failed, redisplay form
            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage;
            return View(model);
        }
Esempio n. 10
0
        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;
                }
            }
        }
 public override void DeleteVendor(Vendor vendor)
 {
     base.DeleteVendor(vendor);
 }
 public override void UpdateVendor(Vendor vendor)
 {
     base.UpdateVendor(vendor);
 }
 public override void InsertVendor(Vendor vendor)
 {
     base.InsertVendor(vendor);
 }
 public static void SetVendor(this Customer customer, Vendor vendor)
 {
     var customerService = EngineContext.Current.Resolve<ICustomerService>();
     customer.VendorId = vendor.Id;
     customerService.UpdateCustomer(customer);
 }
Esempio n. 15
0
        /// <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);
        }
Esempio n. 16
0
 protected virtual void UpdatePictureSeoNames(Vendor vendor)
 {
     var picture = _pictureService.GetPictureById(vendor.PictureId);
     if (picture != null)
         _pictureService.SetSeoFilename(picture.Id, _pictureService.GetPictureSeName(vendor.Name));
 }
Esempio n. 17
0
        protected virtual List<LocalizedProperty> UpdateLocales(Vendor vendor, VendorModel model)
        {
            List<LocalizedProperty> localized = new List<LocalizedProperty>();

            foreach (var local in model.Locales)
            {
                var seName = vendor.ValidateSeName(local.SeName, local.Name, false);
                _urlRecordService.SaveSlug(vendor, seName, local.LanguageId);

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Description",
                    LocaleValue = local.Description
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "MetaDescription",
                    LocaleValue = local.MetaDescription
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "MetaKeywords",
                    LocaleValue = local.MetaKeywords
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "MetaTitle",
                    LocaleValue = local.MetaTitle
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Name",
                    LocaleValue = local.Name
                });

            }
            return localized;
        }