public void UpdateSellerCompanyLogo(SellerCompanyLogo sellerCompanyLogo)
 {
     if (sellerCompanyLogo == null)
         throw new ArgumentNullException("SellerCompanyLogo");
     _sellerCompanyLogoRepository.Update(sellerCompanyLogo);
 }
Exemple #2
0
        //[ValidateAntiForgeryToken]
        public async Task<ActionResult> Register(RegisterViewModel model)
        {

            //if (ModelState.IsValid)
            //{
            try
            {
                var user = new ApplicationUser() { UserName = model.UserName };
                string userrolename = "Users";
                if (!RoleManager.RoleExists(userrolename))
                {

                    var roleresult = RoleManager.Create(new IdentityRole(userrolename));

                }
                var uid = 0;
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    var result2 = UserManager.AddToRole(user.Id, userrolename);
                    if (user != null)
                    {
                        AspNetUsersAdditionalInfo objAspNetUsersAdditionalInfo = new AspNetUsersAdditionalInfo();
                        objAspNetUsersAdditionalInfo.UserKey = user.Id;
                        objAspNetUsersAdditionalInfo.CreatedOn = DateTime.Now;
                        objAspNetUsersAdditionalInfo.IsRemoved = false;
                        objAspNetUsersAdditionalInfo.CreatedFromIP = Request.ServerVariables["REMOTE_ADDR"].ToString();
                        objAspNetUsersAdditionalInfo.SellerTypeID = Convert.ToInt32(this.RouteData.Values["Id"]);
                        _aspNetUsersAdditionalInfoService.InsertAspNetUsersAdditionalInfo(objAspNetUsersAdditionalInfo);
                        if (objAspNetUsersAdditionalInfo.ID > 0)
                        {
                            SellerPersonalInfo objSellerPersonalInfo = new SellerPersonalInfo();
                            objSellerPersonalInfo.UserID = objAspNetUsersAdditionalInfo.ID;
                            objSellerPersonalInfo.Title = model.Salutation.ToString();
                            objSellerPersonalInfo.FirstName = model.FirstName.ToString();
                            objSellerPersonalInfo.LastName = model.LastName.ToString();
                            objSellerPersonalInfo.Address = model.Address.ToString();
                            objSellerPersonalInfo.Email = model.Email.ToString();
                            objSellerPersonalInfo.ContactNo = model.Phone.ToString();
                            objSellerPersonalInfo.PostalCode = model.PostalCode.ToString();
                            _sellerPersonalInfoService.InsertSellerPersonalInfo(objSellerPersonalInfo);
                            if (objSellerPersonalInfo.ID > 0)
                            {
                                if (Convert.ToInt32(this.RouteData.Values["Id"]) == 2)
                                {
                                    SellerCompanyInfo objSellerCompanyInfo = new SellerCompanyInfo();
                                    objSellerCompanyInfo.UserID = objAspNetUsersAdditionalInfo.ID;
                                    objSellerCompanyInfo.CompanyTypeID = Convert.ToInt32(model.CompanyTypeID);
                                    objSellerCompanyInfo.CompanyName = model.CompanyName;
                                    objSellerCompanyInfo.Address001 = model.Address;
                                    objSellerCompanyInfo.CityID = 1;
                                    objSellerCompanyInfo.CountryID = Convert.ToInt32(model.CountryID);
                                    objSellerCompanyInfo.PostalCode = model.CompanyPostalCode;
                                    objSellerCompanyInfo.ContactNumbers = model.CompanyContact + "," + model.CompanyContact2 + "," + model.CompanyContact3;
                                    objSellerCompanyInfo.CompanyNumber = model.CompanyNumber;
                                    if (objSellerCompanyInfo.VatNumber != null)
                                        objSellerCompanyInfo.VatNumber = model.VATNumber;
                                    if (objSellerCompanyInfo.YearOfFoundation != null)
                                        objSellerCompanyInfo.YearOfFoundation = Convert.ToInt32(model.YearofFoundation);
                                    if (objSellerCompanyInfo.NoOfEmployees != null)
                                        objSellerCompanyInfo.NoOfEmployees = Convert.ToInt32(model.NoOfEmployee);
                                    if (objSellerCompanyInfo.TurnOver != null)
                                        objSellerCompanyInfo.TurnOver = (decimal)Decimal.Parse(model.TurnOver, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
                                    objSellerCompanyInfo.CategoryID = 1;
                                    _sellerCompanyInfoService.InsertSellerCompanyInfo(objSellerCompanyInfo);
                                    if (objSellerCompanyInfo.ID > 0)
                                    {
                                        if (!string.IsNullOrEmpty(model.CompanyLogo))
                                        {
                                            SellerCompanyLogo objSellerCompanyLogo = new SellerCompanyLogo();
                                            objSellerCompanyLogo.CompanyID = objSellerCompanyInfo.ID;
                                            objSellerCompanyLogo.Filename = model.CompanyLogo;
                                            objSellerCompanyLogo.FolderPath = "~/Content/Assets/CompanyLogos";
                                            objSellerCompanyLogo.OriginalFilename = model.CompanyLogo;
                                            objSellerCompanyLogo.UploadedOn = DateTime.Now;
                                            objSellerCompanyLogo.ImageSizeID = 1;
                                            _sellerCompanyLogoService.InsertSellerCompanyLogo(objSellerCompanyLogo);
                                        }
                                    }
                                }
                                await SignInAsync(user, isPersistent: false);
                                return RedirectToAction("Index", "Home");
                            }
                            else
                            {
                                ModelState.AddModelError("", "Registration is not done, please register after sometime later.");
                                return View();

                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Registration is not done, please register after sometime later.");
                            return View();

                        }

                    }
                    else
                    {
                        ModelState.AddModelError("", "Registration is not done, please register after sometime later.");
                        return View();

                    }

                }
                else
                {
                    AddErrors(result);
                    
                    var countryList = _countryService.GetAllCountry();
                    if (countryList != null)
                    {
                        foreach (var item in countryList)
                        {
                            model.CountryList.Add(new Country
                            {
                                CountryName = item.CountryName,
                                ID = item.ID
                            });

                        }
                    }
                    var companyTypeList = _companyTypeService.GetAllCompanyType();
                    if (companyTypeList != null)
                    {
                        foreach (var item in companyTypeList)
                        {
                            model.CompanyTypeList.Add(new SelectListItem
                            {
                                Text = item.CompanyType1,
                                Value = item.ID.ToString()
                            });
                        }
                    }
                

                }
               
            }
            catch (Exception ex)
            { }
            return View(model);
        }
 public void InsertSellerCompanyLogo(SellerCompanyLogo sellerCompanyLogo)
 {
     if (sellerCompanyLogo == null)
         throw new ArgumentNullException("SellerCompanyLogo");
     _sellerCompanyLogoRepository.Insert(sellerCompanyLogo);
 }