public async Task <string> CreateCustomerProfile(CustomerProfiles customerProfile)
        {
            _context.Add(customerProfile);
            var result = await _context.SaveChangesAsync();

            var createdCustomerEmail = (await _context.CustomerProfile.FirstAsync(s => s.CustomerEmail == customerProfile.CustomerEmail)).CustomerEmail;

            return(createdCustomerEmail);
        }
        public async Task <string> UpdateCustomer(CustomerProfiles customerProfiles)
        {
            _context.CustomerProfile.Update(customerProfiles);
            var result = await _context.SaveChangesAsync();

            var updatedCustomerEmail = customerProfiles.CustomerEmail;

            return(updatedCustomerEmail);
        }
        public async Task <IActionResult> UpdateCustomerProfile([FromQuery] string email)
        {
            var message = TempData["message"];

            email = HttpContext.Session.GetString("username");
            CustomerProfiles customerProfiles = await _customerProfileService.CustomerProfile(email);

            CustomerProfileViewModel customerProfileViewModel = new CustomerProfileViewModel {
                customerDto = customerProfiles, Message = message?.ToString() ?? string.Empty
            };

            return(View("UpdateCustomerProfile", customerProfileViewModel));
        }
Пример #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ErrorForm.Visible = false;
            SuccesForm.Visible = false;
           
                if (!Bitrix.Security.BXPrincipal.Current.Identity.IsAuthenticated)
                {
                    Redirect("/lk/customer");
                }
                else
                {

                    CustomerProfilesCollection list = BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.GetList(
                        new BXFilter(new IBXFilterItem[1]
                                    {
                                     (IBXFilterItem) new BXFilterItem(BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.Fields.login, BXSqlFilterOperators.Equal, (object) Bitrix.Security.BXPrincipal.Current.Identity.Name)
                                    }),
                        new BXOrderBy(new BXOrderByPair[1]
                                    {
                                        new BXOrderByPair(BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.Fields.registration_date, BXOrderByDirection.Asc)
                                    }));

                    if (list.Count() > 0)
                    {
                        customerProfile = list[0];

                        if (!IsPostBack)
                        {
                            name.Text = customerProfile.name;
                            secondname.Text = customerProfile.secondname;
                            midlename.Text = customerProfile.midlename;
                            pasportdate.Text = customerProfile.pasport_date.ToShortDateString();
                            pasportser.Text = customerProfile.pasport_ser;
                            pasportnum.Text = customerProfile.pasport_num;
                            pasportufms.Text = customerProfile.pasport_ufms;
                            pasportufms_code.Text = customerProfile.pasport_ufms_code;
                            addresreg.Text = customerProfile.address_reg;
                            addressfakt.Text = customerProfile.address_fact;
                            phonenumber.Text = customerProfile.gsmnumber;
                            address_email.Text = customerProfile.address_email;
                        }
                    }
                

            }

            


        }
        public async Task <IActionResult> InsertCustomerProfile(CustomerProfileViewModel customerProfileViewModel)
        {
            CustomerProfiles customer = customerProfileViewModel.customerDto;

            customer.CustomerType    = "Normal";
            customer.CustomerActive  = true;
            customer.CreatedBy       = "System";
            customer.CreatedTime     = DateTime.Now;
            customer.LastUpdatedBy   = "System";
            customer.LastUpdatedTime = DateTime.Now;
            customer.VersionNo       = 1;
            customer.IsDeleted       = false;
            string result = await _customerProfileService.CreateCustomer(customer);

            return(View("SuccessCustomerClick", customerProfileViewModel));
        }
Пример #6
0
        public async Task <string> UpdateCustomer(CustomerProfiles customerProfiles)
        {
            string apiURL = URLConfig.CustomerProfile.UpdateCustomerAPI(_apiUrls.CustomerProfileAPI_Update);

            var payLoad  = new StringContent(JsonConvert.SerializeObject(customerProfiles), Encoding.UTF8, "application/json");
            var response = await _apiClient.PostAsync(apiURL, payLoad);

            if (!response.IsSuccessStatusCode)
            {
                return("Success");
            }

            var updatedCustomerEmail = customerProfiles.CustomerEmail;

            return(updatedCustomerEmail);
        }
Пример #7
0
        public async Task <string> CreateCustomer(CustomerProfiles customer)
        {
            string apiURL = URLConfig.CustomerProfile.InsertCustomerProfileAPI(_apiUrls.CustomerProfileAPI_Insert);

            var payLoad  = new StringContent(JsonConvert.SerializeObject(customer), Encoding.UTF8, "application/json");
            var response = await _apiClient.PostAsync(apiURL, payLoad);

            if (!response.IsSuccessStatusCode)
            {
                return("Success");
            }

            var createdCustomerEmail = Convert.ToString(await response.Content.ReadAsStringAsync());

            return(createdCustomerEmail);
        }
Пример #8
0
        private CustomerRepository GetCustomerRepository(string dbName)
        {
            var dbContextOptions = new DbContextOptionsBuilder <CustomerDbContext>()
                                   .UseInMemoryDatabase(dbName)
                                   .Options;
            var dbContext = new CustomerDbContext(dbContextOptions);

            CreateCustomers(dbContext);

            var productsProfile     = new CustomerProfiles();
            var mapperConfiguration = new MapperConfiguration(cnfg => cnfg.AddProfile(productsProfile));
            var mapper = new Mapper(mapperConfiguration);

            var productsRepository = new CustomerRepository(dbContext, null, mapper);

            return(productsRepository);
        }
        public async Task <string> UpdateCustomer([FromBody] CustomerProfiles customerProfiles)
        {
            var result = await _repository.UpdateCustomer(customerProfiles);

            return(result);
        }
        public async Task <IActionResult> UpdateCustomerProfile(CustomerProfileViewModel customerProfileViewModel)
        {
            CustomerProfiles customer = customerProfileViewModel.customerDto;

            string stringToCheck = customer.PostalCode;

            List <CodeTable> centralRegion = await _recommendationService.GetCentralRegionByPostalCode();

            List <CodeTable> eastRegion = await _recommendationService.GetEastRegionByPostalCode();

            List <CodeTable> northRegion = await _recommendationService.GetNorthRegionByPostalCode();

            List <CodeTable> NERegion = await _recommendationService.GetNERegionByPostalCode();

            List <CodeTable> westRegion = await _recommendationService.GetWestRegionByPostalCode();

            foreach (var x in centralRegion)
            {
                if (stringToCheck.Substring(0, 2) == x.Code)
                //if(stringToCheck.Contains(x.Code))
                {
                    customer.Region = "Central";
                }
            }

            foreach (var x in eastRegion)
            {
                if (stringToCheck.Substring(0, 2) == x.Code)
                {
                    customer.Region = "East";
                }
            }

            foreach (var x in northRegion)
            {
                if (stringToCheck.Substring(0, 2) == x.Code)
                {
                    customer.Region = "North";
                }
            }

            foreach (var x in NERegion)
            {
                if (stringToCheck.Substring(0, 2) == x.Code)
                {
                    customer.Region = "North-East";
                }
            }

            foreach (var x in westRegion)
            {
                if (stringToCheck.Substring(0, 2) == x.Code)
                {
                    customer.Region = "West";
                }
            }

            await _customerProfileService.UpdateCustomer(customer);

            var username = HttpContext.Session.GetString("username");

            TempData["message"] = "Updated Successfully";
            var result = await _customerProfileService.CustomerProfile(username);

            return(RedirectToAction("UpdateCustomerProfile", new { customerEmail = result.CustomerEmail }));
        }
        public async Task <IActionResult> SuccessfulCustomerClick(CustomerProfileViewModel customerProfileViewModel)
        {
            CustomerProfiles resultSet = await _customerProfileService.CustomerProfile(customerProfileViewModel.customerEmail);

            return(View("SuccessCustomerClick", resultSet));
        }
Пример #12
0
        public async Task <IActionResult> Register(RegisterViewModel registerViewModel, CustomerProfiles customer)
        {
            var user = registerViewModel.UserDto;

            if (registerViewModel.UserDto.UserType == 2 && registerViewModel.UserDto.UserName != null && registerViewModel.UserDto.Password != null)
            {
                customer.CustomerEmail    = user.UserName;
                customer.CustomerFullName = "not set";
                customer.CustomerPhone    = "not set";
                customer.CustomerGender   = "Not set";
                customer.CustomerAddress  = "not set";
                customer.CustomerDOB      = DateTime.Today;
                customer.CustomerType     = "Normal";
                customer.CustomerActive   = true;
                customer.CreatedBy        = "System";
                customer.CreatedTime      = DateTime.Now;
                customer.LastUpdatedBy    = "System";
                customer.LastUpdatedTime  = DateTime.Now;
                customer.VersionNo        = 1;
                customer.IsDeleted        = false;
                customer.PostalCode       = "not set";
                customer.Region           = "not set";
                string insertCustomerData = await _customerProfileService.CreateCustomer(customer);
            }

            User result = await _loginService.RegisterAsync(user);

            if (result != null)
            {
                HttpContext.Session.SetInt32("usertype", result.UserType);
                HttpContext.Session.SetInt32("userid", result.UserId);
                HttpContext.Session.SetString("username", result.UserName);

                if (result.UserType == 1)
                {
                    await _shopProfileService.InsertAsync(new ShopProfile { UserId = result.UserId });

                    return(Redirect("/PromotionByShopId"));
                }
                else
                {
                    return(Redirect("/PromotionByRecommendation"));
                }
            }

            ModelState.AddModelError("Register Failed", "Register Failed");

            return(View());
        }