private void button1_Click(object sender, EventArgs e)
        {
            //todo validation ko code afaile lekhne
            var model = new CustomerUserModel()
            {
                Address  = txtAddress.Text,
                Email    = txtEmail.Text,
                Name     = txtName.Text,
                Password = txtPassword.Text,
                Phone    = txtPhone.Text,
                UserName = txtUserName.Text
            };
            var res = customerUser.Insert(model);

            if (res)
            {
                MessageBox.Show("Records added");
                LoadData();
                CLearAll();
            }
            else
            {
                MessageBox.Show("Some error occured");
            }
        }
        public async Task <CustomerByTokenIdQueryResponse> Handle(CustomerByTokenIdQueryRequest request, CancellationToken cancellationToken)
        {
            var userId = _currentUser.GetUserId();
            var user   = await _userManager.Users.Include(a => a.Gender)
                         .FirstOrDefaultAsync(a => a.UserType == UserType.customer && a.SubjectId.ToString() == userId, cancellationToken: cancellationToken);

            if (user is null)
            {
                throw new AppException(ResultCode.BadRequest, "user not found");
            }

            var customer = new CustomerUserModel
            {
                Birthday    = user.Birthday,
                Email       = user.Email,
                FirstName   = user.FirstName,
                GenderName  = user.Gender.Name,
                GenderId    = user.GenderId,
                LastName    = user.LastName,
                UserName    = user.UserName,
                PhoneNumber = user.PhoneNumber
            };

            return(new CustomerByTokenIdQueryResponse(true, customer));
        }
Exemplo n.º 3
0
        public CustomerUserModel PartnerLogin(string email, string password, string culture)
        {
            CustomerUserModel model = null;

            try
            {
                IUnitOfWork        ouw     = new UnitOfWork();
                ICompanyRepository rep     = new CompanyRepository(ouw);
                ICompanyService    service = new CompanyService(rep);
                var data = service.GetCustomerByUser(email, password, culture, true);

                if (data != null)
                {
                    model                 = new CustomerUserModel();
                    model.ID              = data.ID;
                    model.RegistrationID  = data.RegistrationID;
                    model.RegistrationNo  = data.RegistrationNo;
                    model.Email           = data.ClientID;
                    model.Name            = data.Name;
                    model.UserType        = (int)TransproUserType.Customer;
                    model.IsAuthenticated = true;
                    return(model);
                }
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                // errorLog.SetErrorLog(model.CurrentUserID, "Customer Login Error for transprologin", message);
                throw new Exception(ex.Message);
            }
            return(model);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([FromForm] CustomerUserModel user)
        {
            var userName = $"{user.CustomerUserName.Trim()}@{user.CustomerName.Trim()}";

            CustomerUser customerUser = null;

            if (this.ModelState.IsValid && userName.IsValidEmail())
            {
                // Only add user if it is the same domain name
                if (this.User.Identity.Name.GetDomainNameFromEmail()
                    == userName.GetDomainNameFromEmail())
                {
                    customerUser = new CustomerUser
                    {
                        UserName     = userName,
                        CreatedDate  = DateTimeOffset.UtcNow,
                        Id           = Guid.NewGuid(),
                        CustomerName = this.User.Identity.Name.GetDomainNameFromEmail()
                    };

                    // Only the admin can land here, and admin's name is the email.
                    // We assume the customer name is  the email domain
                    _ = await this.customerManagementStore.AddUserAsync(customerUser);

                    return(this.RedirectToAction(nameof(this.Index)));
                }
            }

            this.ModelState.AddModelError("Username", "User name is not a valid email.");
            return(this.View(customerUser));
        }
Exemplo n.º 5
0
        // GET: CustomerUsers/Home/Create
        public IActionResult Create()
        {
            var createUserModel = new CustomerUserModel
            {
                CustomerName = this.User.Identity.Name.GetDomainNameFromEmail(), CustomerUserName = ""
            };

            return(this.View(createUserModel));
        }
Exemplo n.º 6
0
 public CustomerInfo GetCustomerInfo(String email)
 {
     using (ISession session = SessionFactory.Create())
     {
         UserPersonalInfoModel userPersonalInfoModel = RepositoriyFactory.GetRepo <IUserPersonalInfoRepositoriy>(session).GetUserPersonalInfo(email);
         CustomerUserModel     customerUser          = RepositoriyFactory.GetRepo <ICustomerUserRepository>(session).GetCustomerUser(userPersonalInfoModel.UserPersonalInfoId);
         CustomerModel         customer = RepositoriyFactory.GetRepo <ICustomerRepository>(session).GetCustomer(customerUser.CustomerId);
         return(CustomerMapper.MapToCustomerInfo(customer));
     }
 }
        public CustomerUserModel GetCustomerUser(Int32 userId)
        {
            CustomerUserModel customerUser = new CustomerUserModel();

            using (IDbConnection db = new SqlConnection(connectionString))
            {
                customerUser = db.QueryFirstOrDefault <CustomerUserModel>($"SELECT * FROM CustomerUser WHERE UserId = {userId}");
            }
            return(customerUser);
        }
Exemplo n.º 8
0
        public ActionResult Index()
        {
            var model = new CustomerUserModel
            {
                CustomerId            = prefix + ShortGuid.NewGuid(),
                CustomerName          = prefix + ShortGuid.NewGuid(),
                CustomerUserEmail     = prefix + ShortGuid.NewGuid() + "@gmail.com",
                CustomerUserId        = prefix + ShortGuid.NewGuid(),
                CustomerUserFirstName = prefix + ShortGuid.NewGuid(),
                CustomerUserLastName  = prefix + ShortGuid.NewGuid()
            };

            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult ZeroConfig()
        {
            ViewBag.Message = "A page to test the ZeroConfig scripts.";
            var model = new CustomerUserModel
            {
                CustomerId            = prefix + ShortGuid.NewGuid(),
                CustomerName          = prefix + ShortGuid.NewGuid(),
                CustomerUserEmail     = prefix + ShortGuid.NewGuid() + "@gmail.com",
                CustomerUserId        = prefix + ShortGuid.NewGuid(),
                CustomerUserFirstName = prefix + ShortGuid.NewGuid(),
                CustomerUserLastName  = prefix + ShortGuid.NewGuid()
            };

            return(View(model));
        }
Exemplo n.º 10
0
        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";
            var model = new CustomerUserModel
            {
                CustomerId            = prefix + ShortGuid.NewGuid(),
                CustomerName          = prefix + ShortGuid.NewGuid(),
                CustomerUserEmail     = prefix + ShortGuid.NewGuid() + "@gmail.com",
                CustomerUserId        = prefix + ShortGuid.NewGuid(),
                CustomerUserFirstName = prefix + ShortGuid.NewGuid(),
                CustomerUserLastName  = prefix + ShortGuid.NewGuid()
            };

            return(View(model));
        }
Exemplo n.º 11
0
        public Address GetBillingAddress(String email)
        {
            using (ISession session = SessionFactory.Create())
            {
                UserPersonalInfoModel userPersonalInfoModel = RepositoriyFactory.GetRepo <IUserPersonalInfoRepositoriy>(session).GetUserPersonalInfo(email);
                CustomerUserModel     customerUser          = RepositoriyFactory.GetRepo <ICustomerUserRepository>(session).GetCustomerUser(userPersonalInfoModel.UserPersonalInfoId);
                CustomerModel         customer         = RepositoriyFactory.GetRepo <ICustomerRepository>(session).GetCustomer(customerUser.CustomerId);
                AddressModel          billingAddress   = RepositoriyFactory.GetRepo <IAddressRepositoriy>(session).GetBilllingAddress("CustomerId", customerUser.CustomerId);
                AddressModel          dedicatedAddress = RepositoriyFactory.GetRepo <IAddressRepositoriy>(session).GetDedicatedAddress(customerUser.CustomerId);

                AddressModel address = (customer.IsThirdPartyBillingEnabled == true) ? dedicatedAddress : billingAddress;

                LocationModel       location = RepositoriyFactory.GetRepo <ILocationRepository>(session).GetLocation(address.AddressId);
                AddressContactModel contact  = RepositoriyFactory.GetRepo <IAddressContactRepositoriy>(session).GetContactPerson(address.AddressId);
                return(BillingAddressMapper.GetBillingAddress(location, contact, address));
            }
        }
        public bool Insert(CustomerUserModel model)
        {
            try
            {
                SqlParameter
                [] parameters = new SqlParameter[6];
                parameters[0] = new SqlParameter("@Name", model.Name);
                parameters[1] = new SqlParameter("@Address", model.Address);
                parameters[2] = new SqlParameter("@Phone", model.Phone);
                parameters[3] = new SqlParameter("@UserName", model.UserName);
                parameters[4] = new SqlParameter("@Password", model.Password);
                parameters[5] = new SqlParameter("@Email", model.Email);

                db.Database.ExecuteSqlCommand("exec SP_CustomerUser @Name, @Address, @Phone, @UserName, @Password, @Email", parameters);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        public int CreateCustomerUser(string _connectionString, CustomerUserModel customerUser)
        {
            int rowsAffected = 0;


            using (var connection = new MySqlConnection(_connectionString))
            {
                connection.Open();

                try
                {
                    rowsAffected = connection.Execute(
                        string.Format("insert into UserCustomer ( fk_UserUID, fk_CustomerUID, StatusInd,LastUserUTC) values ({0}, {1},@StatusInd,@LastUserUTC);"
                                      , customerUser.UserUID.ToStringWithoutHyphens().WrapWithUnhex(),
                                      customerUser.CustomerUID.ToStringWithoutHyphens().WrapWithUnhex()),
                        new
                    {
                        StatusInd   = 1,
                        LastUserUTC = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")
                    });

                    connection.Close();
                }
                catch (MySqlException ex)
                {
                    if (!ex.Message.Contains("Duplicate"))
                    {
                        throw;
                    }
                }
                finally
                {
                    connection.Close();
                }
            }
            return(rowsAffected);
        }
Exemplo n.º 14
0
 public ActionResult ZeroConfig(CustomerUserModel model)
 {
     return(View(model));
 }