Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public UserJsonModel(User user)
 {
     Id = user.Id;
     Login = user.Login;
     Subdomain = user.Subdomain;
     Company = user.Company;
     Brand = user.Brand;
     Fio = user.FIO;
     Email = user.Email;
     Skype = user.Skype;
     ICQ = user.ICQ;
     Url = user.Url;
     Country = user.Country;
     Region = user.Region;
     City = user.City;
     About = user.About;
     Address = user.Address;
     ZIP = user.ZIP;
     PostCode = user.PostCode;
     if (user.UserOccupationInfos != null)
     {
         Importer = user.UserOccupationInfos.Importer;
         OEM = user.UserOccupationInfos.OEM;
         Whoseller = user.UserOccupationInfos.Whoseller;
         Exporter = user.UserOccupationInfos.Exporter;
         ODM = user.UserOccupationInfos.ODM;
         SingleSeller = user.UserOccupationInfos.SingleSeller;
         Developer = user.UserOccupationInfos.Developer;
         Agent = user.UserOccupationInfos.Agent;
     }
     if (user.UserLegalInfos != null)
     {
         OGRN = user.UserLegalInfos.OGRN;
         INN = user.UserLegalInfos.INN;
         KPP = user.UserLegalInfos.KPP;
         AccountRNumber = user.UserLegalInfos.AccountRNumber;
         AccountKNumber = user.UserLegalInfos.AccountKNumber;
         Bank = user.UserLegalInfos.AccountBank;
         BankBIK = user.UserLegalInfos.AccountBankBIK;
     }
     Tariff = user.Tarif;
     TariffExpiration = user.TariffExpiration.FormatDateTime();
     Dealer = user.Dealer;
     RegDate = user.Date.FormatDate();
 }
Пример #2
0
        // Метод для тестовой рассылки письма
        private void SendMail(User user)
        {
            const string subject = "Вопрос от пользователя Дядя Коля";
            var template =
                new ParametrizedFileTemplate(
                    Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "Mail", "UserQuestion.html"), new
                    {
                        Subject = subject
                    });

            Locator.GetService<IMailNotificationManager>().Notify(user, subject, template.ToString());
        }
Пример #3
0
        public ActionResult SaveCompanyProfile(User model, FormCollection collection)
        {
            if (!IsAuthentificated)
            {
                return RedirectToAction("Register");
            }

            // Сохраняем
            // Основное инфо
            CurrentUser.Company = model.Company;
            CurrentUser.Brand = model.Brand;
            CurrentUser.FIO = model.FIO;

            // Основной телефон
            var mainPhone = CurrentUser.GetMainUserPhone();
            if (mainPhone.User == null)
            {
                mainPhone.User = CurrentUser;
                mainPhone.Type = (short) CustomPhoneType.MainPhone;
                CurrentUser.UserPhones.Add(mainPhone);
            }
            mainPhone.CountryCode = collection["PhoneCountryCode"];
            mainPhone.CityCode = collection["PhoneCityCode"];
            mainPhone.PhoneNumber = collection["PhoneNumber"];

            // Факс
            var faxPhone = CurrentUser.GetMainFaxPhone();
            if (faxPhone.User == null)
            {
                faxPhone.User = CurrentUser;
                faxPhone.Type = (short) CustomPhoneType.MainFax;
                CurrentUser.UserPhones.Add(faxPhone);
            }
            faxPhone.CountryCode = collection["FaxCountryCode"];
            faxPhone.CityCode = collection["FaxCityCode"];
            faxPhone.PhoneNumber = collection["FaxNumber"];

            // Сотовый
            var cellPhone = CurrentUser.GetMainCellPhone();
            if (cellPhone.User == null)
            {
                cellPhone.User = CurrentUser;
                cellPhone.Type = (short) CustomPhoneType.MainCell;
                CurrentUser.UserPhones.Add(cellPhone);
            }
            cellPhone.CountryCode = collection["CellPhoneCountryCode"];
            cellPhone.CityCode = collection["CellPhoneCityCode"];
            cellPhone.PhoneNumber = collection["CellPhoneNumber"];

            // Другие контакты
            CurrentUser.Skype = model.Skype;
            CurrentUser.ICQ = model.ICQ;
            CurrentUser.Url = model.Url;
            CurrentUser.Country = model.Country;
            CurrentUser.Region = model.Region;
            CurrentUser.Address = model.Address;
            CurrentUser.City = model.City;
            CurrentUser.PostCode = model.PostCode;

            // Деятельность
            if (CurrentUser.UserOccupationInfos == null)
            {
                CurrentUser.UserOccupationInfos = new UserOccupationInfo()
                    {
                        User = CurrentUser
                    };
            }
            CurrentUser.UserOccupationInfos.Importer = model.UserOccupationInfos.Importer;
            CurrentUser.UserOccupationInfos.OEM = model.UserOccupationInfos.OEM;
            CurrentUser.UserOccupationInfos.Whoseller = model.UserOccupationInfos.Whoseller;
            CurrentUser.UserOccupationInfos.Exporter = model.UserOccupationInfos.Exporter;
            CurrentUser.UserOccupationInfos.ODM = model.UserOccupationInfos.ODM;
            CurrentUser.UserOccupationInfos.SingleSeller = model.UserOccupationInfos.SingleSeller;
            CurrentUser.UserOccupationInfos.Developer = model.UserOccupationInfos.Developer;
            CurrentUser.UserOccupationInfos.Agent = model.UserOccupationInfos.Agent;
            CurrentUser.UserOccupationInfos.Distributor = model.UserOccupationInfos.Distributor;

            // О компании
            CurrentUser.About = model.About;

            // Банковские реквизиты
            if (CurrentUser.UserLegalInfos == null)
            {
                CurrentUser.UserLegalInfos = new UserLegalInfo()
                {
                    User = CurrentUser
                };
            }
            CurrentUser.UserLegalInfos.OGRN = model.UserLegalInfos.OGRN;
            CurrentUser.UserLegalInfos.INN = model.UserLegalInfos.INN;
            CurrentUser.UserLegalInfos.KPP = model.UserLegalInfos.KPP;
            CurrentUser.UserLegalInfos.AccountRNumber = model.UserLegalInfos.AccountRNumber;
            CurrentUser.UserLegalInfos.AccountKNumber = model.UserLegalInfos.AccountKNumber;
            CurrentUser.UserLegalInfos.AccountBank = model.UserLegalInfos.AccountBank;
            CurrentUser.UserLegalInfos.AccountBankBIK = model.UserLegalInfos.AccountBankBIK;

            // Дилер
            CurrentUser.Dealer = model.Dealer;

            // Сохраняем фотографии товара и контактного лица
            var logoImage = Request.Files["LogoImage"];
            if (logoImage != null && logoImage.ContentLength > 0 && logoImage.ContentType.Contains("image"))
            {
                var fileName = String.Format("logo-{0}-{1}{2}", CurrentUser.Id,
                                             new Random(System.Environment.TickCount).Next(Int32.MaxValue),
                                             Path.GetExtension(logoImage.FileName));
                FileUtils.SavePostedFile(logoImage, "userimage", fileName);
                CurrentUser.LogoUrl = fileName;
            }
            var fioImage = Request.Files["FIOImage"];
            if (fioImage != null && fioImage.ContentLength > 0 && fioImage.ContentType.Contains("image"))
            {
                var fileName = String.Format("fio-{0}-{1}{2}", CurrentUser.Id,
                                             new Random(System.Environment.TickCount).Next(Int32.MaxValue),
                                             Path.GetExtension(fioImage.FileName));
                FileUtils.SavePostedFile(fioImage, "userimage", fileName);
                CurrentUser.FIOImg = fileName;
            }

            // Сохраняем
            UsersRepository.SubmitChanges();

            return View("ProfileSaved");
        }
Пример #4
0
        public ActionResult Register(RegistrationModel model)
        {
            // Проверяем уникальность пользователя
            var exists = UsersRepository.ExistsUserWithLogin(model.Email);
            if (exists)
            {
                ViewBag.message = "На сайте уже зарегистрирован пользователь с таким адресом";
                TempData["UserExists"] = true;
                return View("RegistrationResult");
            }

            // Проверяем соответствие кода каптчи
            var solution = Session["reg_captcha"];
            if (solution == null || solution.ToString() != model.CaptchaValue)
            {
                ViewBag.message = "Не правильный код подтверждения каптчи";
                return View("RegistrationResult");
            }

            // Видимо все ок - создаем нового пользователя
            var newUser = new User()
                {
                    Company = model.OrganizationName,
                    Address = model.Address,
                    City = model.City,
                    Region = model.Region,
                    Login = model.Email,
                    Email = model.Email,
                    Phone = String.Format("{0}{1}{2}", model.CountryCode, model.CityCode, model.PhoneNumber),
                    Url = model.Website,
                    PasswordHash = PasswordUtils.QuickMD5(model.Password),
                    Country = model.Country,
                    Date = DateTime.Now,
                    Tarif = "free"
                };
            newUser.UserPhones.Add(new UserPhone()
                {
                    User = newUser,
                    CityCode = model.CityCode,
                    CountryCode = model.CountryCode,
                    PhoneNumber = model.PhoneNumber
                });
            UsersRepository.Add(newUser);
            UsersRepository.SubmitChanges();

            // Уведомляем об успешном создании
            ViewBag.message = "Вы были успешно зарегистрированы на нашем сайте. Теперь вы можете войти в личный кабинет и добавить свои товары в наш каталог";
            return View("RegistrationResult");
        }
Пример #5
0
 /// <summary>
 /// Нотифицирует указанного пользователя сообщением по электронной почте
 /// </summary>
 /// <param name="user">Пользователь</param>
 /// <param name="title">Заголовок письма</param>
 /// <param name="content">Содержимое письма</param>
 public void Notify(User user, string title, string content)
 {
     Notify(user.Email,title,content);
 }
Пример #6
0
 /// <summary>
 /// Авторизирует текущего пользователя
 /// </summary>
 /// <param name="user">Пользователь которого установить как текущего</param>
 /// <param name="remember">Запомнить ли пользователя</param>
 public void AuthorizeUser(User user, bool remember = true)
 {
     CurrentUser = user;
     if (remember)
     {
         // Устанавливаем собственные авторизационные куки
         var authCookie = new HttpCookie("auth");
         authCookie.Values["identity"] = user.Login;
         authCookie.Values["pass"] = user.PasswordHash;
         authCookie.Expires = DateTime.Now.AddDays(7);
         Response.Cookies.Add(authCookie);
     }
 }
Пример #7
0
 /// <summary>
 /// Обновляет пользователя из модели
 /// </summary>
 /// <param name="user"></param>
 public void UpdateUser(User user)
 {
     user.Id = this.Id;
     user.Login = this.Login;
     user.Subdomain = this.Subdomain;
     user.Company = this.Company;
     user.Brand = this.Brand;
     user.FIO = this.Fio;
     user.Email = this.Email;
     user.Skype = this.Skype;
     user.ICQ = this.ICQ;
     user.Url = this.Url;
     user.Country = this.Country;
     user.Region = this.Region;
     user.City = this.City;
     user.About = this.About;
     user.Address = this.Address;
     user.ZIP = this.ZIP;
     user.PostCode = this.PostCode;
     if (user.UserOccupationInfos == null)
     {
         user.UserOccupationInfos = new UserOccupationInfo()
         {
             User = user
         };
     }
     user.UserOccupationInfos.Importer = this.Importer;
     user.UserOccupationInfos.OEM = this.OEM;
     user.UserOccupationInfos.Whoseller = this.Whoseller;
     user.UserOccupationInfos.Exporter = this.Exporter;
     user.UserOccupationInfos.ODM = this.ODM;
     user.UserOccupationInfos.SingleSeller = this.SingleSeller;
     user.UserOccupationInfos.Developer = this.Developer;
     user.UserOccupationInfos.Agent = this.Agent;
     if (user.UserLegalInfos == null)
     {
         user.UserLegalInfos = new UserLegalInfo()
             {
                 User = user
             };
     }
     user.UserLegalInfos.OGRN = this.OGRN;
     user.UserLegalInfos.INN = this.INN;
     user.UserLegalInfos.KPP = this.KPP;
     user.UserLegalInfos.AccountRNumber = this.AccountRNumber;
     user.UserLegalInfos.AccountKNumber = this.AccountKNumber;
     user.UserLegalInfos.AccountBank = this.Bank;
     user.UserLegalInfos.AccountBankBIK = this.BankBIK;
     user.Dealer = this.Dealer;
 }