Esempio n. 1
0
        public ActionResult Address()
        {
            string SnNum = WebUtil.GetQueryStringValue <string>("SnNum", string.Empty);

            if (SnNum.IsEmpty())
            {
                ViewBag.CusAddress = new CusAddressEntity();
                return(View());
            }
            else
            {
                List <CusAddressEntity> list = Session[CacheKey.JOOSHOW_CUSADDRESS_CACHE] as List <CusAddressEntity>;
                if (!list.IsNullOrEmpty())
                {
                    CusAddressEntity entity = list.FirstOrDefault(a => a.SnNum == SnNum);
                    entity             = entity.IsNull() ? new CusAddressEntity() : entity;
                    ViewBag.CusAddress = entity;
                }
                else
                {
                    CustomerProvider provider = new CustomerProvider();
                    CusAddressEntity entity   = provider.GetSingleAddress(SnNum);
                    entity             = entity == null ? new CusAddressEntity() : entity;
                    ViewBag.CusAddress = entity;
                }
                return(View());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 删除地址
        /// </summary>
        /// <returns></returns>
        public ActionResult DelAddress()
        {
            string           CompanyID  = WebUtil.GetFormValue <string>("CompanyID");
            string           SnNum      = WebUtil.GetFormValue <string>("SnNum");
            string           CustomerSN = WebUtil.GetFormValue <string>("CustomerSN");
            CustomerProvider provider   = new CustomerProvider(CompanyID);
            int        line             = provider.DeleteAddress(SnNum, CustomerSN);
            DataResult result           = null;

            if (line > 0)
            {
                result = new DataResult()
                {
                    Code = (int)EResponseCode.Success, Message = "删除成功"
                };
            }
            else
            {
                result = new DataResult()
                {
                    Code = (int)EResponseCode.Exception, Message = "删除失败"
                };
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 3
0
 public async Task <JsonResult> Get(int id)
 {
     using (CustomerProvider customerProvider = new CustomerProvider())
     {
         return(Json(await customerProvider.GetByIDAsync(id), JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 4
0
        public MembershipResult ResetPassowrd(ResetPasswordRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            MembershipResult result = new MembershipResult();
            var customer            = CustomerProvider.QueryByUserName(request.Username);

            #region Validation
            if (customer == null)
            {
                result.Errors.Add("The customer does not exists.".Localize());
            }
            if (request.ResetPasswordToken != customer.Membership.ResetPasswordToken)
            {
                result.Errors.Add("Invalid token.".Localize());
            }
            #endregion

            if (result.Success)
            {
                var encryptedPwd = PasswordEncryptor.EncryptPassword(request.NewPassword, customer.Membership.PasswordSalt);
                customer.Membership.Password           = encryptedPwd;
                customer.Membership.ResetPasswordToken = null;
                CustomerService.Update(customer);
            }

            return(result);
        }
Esempio n. 5
0
        protected override void OnInitializeTask()
        {
            CloseDocuments();

            _logReport              = new StringBuilder();
            _projectInfo            = Project.GetProjectInfo();
            _segmentBuilder         = new SegmentBuilder();
            _pathInfo               = new PathInfo();
            _customerProvider       = new CustomerProvider();
            _imageService           = new ImageService();
            _reportService          = new ReportService();
            _projectSettingsService = new ProjectSettingsService();
            _exportSettings         = GetSetting <XliffManagerExportSettings>();
            if (_exportSettings.ExportOptions == null)
            {
                CreateDefaultContext();
            }

            _isError = false;
            _xliffManagerController = GetXliffManagerController();

            CreateWizardContext();
            WriteLogReportHeader();
            SubscribeToWindowClosing();

            _logReport.AppendLine();
            _logReport.AppendLine("Phase: Export - Started " + FormatDateTime(DateTime.UtcNow));

            base.OnInitializeTask();
        }
Esempio n. 6
0
        public ActionResult GetCustomerList()
        {
            int    pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1);
            int    pageSize  = WebUtil.GetFormValue <int>("pageSize", 15);
            string CusNum    = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            int    CusType   = WebUtil.GetFormValue <int>("CusType", 0);

            CustomerProvider provider = new CustomerProvider();
            CustomerEntity   entity   = new CustomerEntity();
            PageInfo         pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };

            if (!CusNum.IsEmpty())
            {
                entity.Begin <CustomerEntity>()
                .Where <CustomerEntity>("CusNum", ECondition.Like, "%" + CusNum + "%")
                .Or <CustomerEntity>("CusName", ECondition.Like, "%" + CusNum + "%")
                .End <CustomerEntity>();
            }
            if (CusType != 0)
            {
                entity.Where <CustomerEntity>(a => a.CusType == CusType);
            }

            List <CustomerEntity> listResult = provider.GetCustomerList(entity, ref pageInfo);
            string json = ConvertJson.ListToJson <CustomerEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Esempio n. 7
0
        public GenerateResetPasswordTokenResult GenerateResetPasswordToken(string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException("username");
            }
            GenerateResetPasswordTokenResult result = new GenerateResetPasswordTokenResult();
            var customer = CustomerProvider.QueryByUserName(username);

            #region Validation
            if (customer == null)
            {
                result.Errors.Add("The customer does not exists.".Localize());
            }
            #endregion
            if (result.Success)
            {
                var token = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10);

                result.Token = token;

                customer.Membership.ResetPasswordToken = token;
                CustomerService.Update(customer);
            }

            return(result);
        }
Esempio n. 8
0
        public ActionResult Add()
        {
            Session[CacheKey.JOOSHOW_CUSADDRESS_CACHE] = null;
            string CusNum = WebUtil.GetQueryStringValue <string>("CusNum", string.Empty);

            if (CusNum.IsEmpty())
            {
                ViewBag.Customer   = new CustomerEntity();
                ViewBag.DdlCusType = EnumHelper.GetOptions <ECusType>("", "请选择客户类别");
                return(View());
            }
            else
            {
                CustomerProvider provider = new CustomerProvider();
                CustomerEntity   entity   = provider.GetSingleCustomer(CusNum);
                entity             = entity == null ? new CustomerEntity() : entity;
                ViewBag.DdlCusType = EnumHelper.GetOptions <ECusType>(entity.CusType, "请选择客户类别");
                ViewBag.Customer   = entity;

                List <CusAddressEntity> listResult = provider.GetAddressList(entity.CusNum);
                if (!listResult.IsNullOrEmpty())
                {
                    Session[CacheKey.JOOSHOW_CUSADDRESS_CACHE] = listResult;
                }
                return(View());
            }
        }
Esempio n. 9
0
        public IActionResult RegisterCustomerWithVehicle(string vrm, string title, string firstname, string lastname, string email, string tel, string address1, string address2, string county, string postcode)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Customer customer = new Customer
            {
                customerID   = JobProvider.GetUniqueKey(8),
                email        = email,
                registered   = DateTime.Today,
                title        = title,
                firstname    = firstname,
                lastname     = lastname,
                addressline1 = address1,
                addressline2 = address2,
                county       = county,
                postcode     = postcode,
                phone        = tel
            };

            CustomerProvider.addCustomer(customer);
            CustomerProvider.assignVehicle(vrm, customer.customerID);

            return(RedirectToAction("BookAddVehicle", "Job", new { vrm = vrm }));
        }
Esempio n. 10
0
        public void Format_InvalidFormat_ThrowsFormatException(string format)
        {
            IFormatProvider cp       = new CustomerProvider();
            Customer        customer = new Customer("Jeffrey Richter", "+1 (425) 555-0100", 1000000);

            Assert.Throws <FormatException>(() => string.Format(cp, "{0:" + format + "}", customer));
        }
Esempio n. 11
0
        /// <summary>
        /// 查询客户地址分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAddressListPage()
        {
            string CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            int    PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);

            string Address = WebUtil.GetFormValue <string>("Address", string.Empty);
            string Phone   = WebUtil.GetFormValue <string>("Phone", string.Empty);
            string CusNum  = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            string CusName = WebUtil.GetFormValue <string>("CusName", string.Empty);
            int    CusType = WebUtil.GetFormValue <int>("CusType", 0);

            CusAddressEntity entity = new CusAddressEntity();

            entity.Address = Address;
            entity.Phone   = Phone;
            entity.CusNum  = CusNum;
            entity.CusName = CusName;

            PageInfo pageInfo = new PageInfo();

            pageInfo.PageIndex = PageIndex;
            pageInfo.PageSize  = PageSize;

            CustomerProvider                  provider = new CustomerProvider(CompanyID);
            List <CusAddressEntity>           list     = provider.GetList(entity, ref pageInfo);
            DataListResult <CusAddressEntity> result   = new DataListResult <CusAddressEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 12
0
        // PUT api/customer/5
        public int Put(int id, CustomerModel model)
        {
            model.Cust_Id = id;
            int i = CustomerProvider.insertCustomer(model);

            return(i);
        }
Esempio n. 13
0
        public string Format_NormalFormat_PositiveTest(string format)
        {
            IFormatProvider cp       = new CustomerProvider();
            Customer        customer = new Customer("Jeffrey Richter", "+1 (425) 555-0100", 1000000);

            return(string.Format(cp, "{0:" + format + "}", customer));
        }
Esempio n. 14
0
        public ActionResult AddCustomer([ModelBinder(typeof(JsonBinder <CustomerEntity>))] CustomerEntity entity)
        {
            List <CusAddressEntity> list = Session[CacheKey.JOOSHOW_CUSADDRESS_CACHE] as List <CusAddressEntity>;

            list = list == null ? new List <CusAddressEntity>() : list;
            CustomerProvider provider = new CustomerProvider();
            int line = 0;

            if (entity.CusNum.IsEmpty())
            {
                entity.CreateTime = DateTime.Now;
                entity.CusNum     = SequenceProvider.GetSequence(typeof(CustomerEntity));
                line = provider.AddCustomer(entity, list);
            }
            else
            {
                line = provider.Update(entity, list);
            }
            if (line > 0)
            {
                this.ReturnJson.AddProperty("d", "success");
            }
            else
            {
                this.ReturnJson.AddProperty("d", "");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Esempio n. 15
0
        public ActionResult Auto(string cusName)
        {
            CustomerProvider      provider = new CustomerProvider();
            List <CustomerEntity> list     = provider.GetList();

            if (!list.IsNullOrEmpty() && !cusName.IsEmpty())
            {
                list = list.Where(a => a.CusNum.Contains(cusName) || a.CusName.Contains(cusName)).ToList();
            }
            list = list.IsNull() ? new List <CustomerEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (CustomerEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("CusNum", t.CusNum);
                jsonObject.AddProperty("CusName", t.CusName);
                //jsonObject.AddProperty("Phone", t.Phone);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Esempio n. 16
0
        /// <summary>
        /// 得到客户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult GetCustomerList(CustomerSearchDTO dto)
        {
            ResultData <List <CustomerInfoModel> > result = new ResultData <List <CustomerInfoModel> >();

            result = CustomerProvider.GetCustomerList(dto);

            return(Json(new { total = result.Count, rows = result.Object }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public static IList <Customer> GetCustomer(CustomerFilterVM customerFilter)
        {
            using (IDataContext model = new NorhWindModel())
            {
                var customer = CustomerProvider.GetCustomer(model, customerFilter);

                return(customer);
            }
        }
Esempio n. 18
0
 public AdministrationController(
     CustomerProvider CustomerProvider,
     EmployeeProvider EmployeeProvider,
     AddressProvider AddressProvider,
     EmailProvider EmailProvider,
     PhoneProvider PhoneProvider) : base(AddressProvider, EmailProvider, PhoneProvider)
 {
     this.CustomerProvider = CustomerProvider;
     this.EmployeeProvider = EmployeeProvider;
 }
Esempio n. 19
0
        private static async Task <CustomerServiceResponse> UpdateCustomerAsync(CustomerRequest request)
        {
            var customerProvider = new CustomerProvider();

            var response = await customerProvider.SendRequestAsync(request, RestActions.Update);

            customerProvider.Close();

            return(response);
        }
Esempio n. 20
0
                public void With_valid_customer_does_not_throw()
                {
                    // Arrange
                    var sut = new CustomerProvider();

                    // Act
                    Action action = () => sut.CreateCustomer(new Customer());

                    // Assert
                    action.Should().NotThrow <Exception>();
                }
Esempio n. 21
0
                public void With_valid_id()
                {
                    // Arrange
                    var sut = new CustomerProvider();

                    // Act
                    var result = sut.GetCustomerById(1);

                    // Assert
                    result.Should().NotBeNull();
                }
Esempio n. 22
0
        // Customer Functions started
        public int AddCustomer(CustomerDTO obj)
        {
            CustomerProvider provider = new CustomerProvider();

            if (provider.GetCustomerById(obj.CustomerId) == null)
            {
                provider.AddCustomer(obj);
                return(1);
            }
            return(-1);
        }
Esempio n. 23
0
        public IActionResult EditCustomer(string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Customer"] = CustomerProvider.getCustomerFromID(customerID);

            return(View("EditCustomer"));
        }
Esempio n. 24
0
        public IActionResult RegisterExistingCustomerWithVehicle(string vrm, string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            CustomerProvider.assignVehicle(vrm, customerID);

            return(RedirectToAction("BookAddVehicle", "Job", new { vrm = vrm }));
        }
Esempio n. 25
0
                public void With_invalid_id_returns_null(int?customerId)
                {
                    // Arrange
                    var sut = new CustomerProvider();

                    // Act
                    var result = sut.GetCustomerById(customerId);

                    // Assert
                    result.Should().BeNull();
                }
Esempio n. 26
0
        // GET

        public IActionResult ViewCustomers()
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Customers"] = CustomerProvider.getAllCustomers();

            return(View("View"));
        }
Esempio n. 27
0
        private void RefreshData()
        {
            string sortString = GetCurrentSortString();
            customerProvider = new CustomerProvider(CustomerSinceDatePicker.DateFrom, CustomerSinceDatePicker.DateTo, sortString);
            var customerList = new AsyncVirtualizingCollection<Customer>(customerProvider, pageSize, timePageInMemory);
            DataContext = customerList;

            UpdateSortingVisualFeedback();

            CustomersDataGrid.SelectedIndex = 0;
        }
Esempio n. 28
0
        public MembershipResult Register(RegistrationRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            MembershipResult result = new MembershipResult();

            #region Validation
            if (string.IsNullOrEmpty(request.Username))
            {
                result.Errors.Add("Invalid username".Localize());
            }
            if (string.IsNullOrEmpty(request.Email) || !Regex.IsMatch(request.Email, Kooboo.RegexPatterns.EmailAddress))
            {
                result.Errors.Add("Invalid email.".Localize());
            }
            if (CustomerProvider.QueryByUserName(request.Username) != null)
            {
                result.Errors.Add("The username already exists.".Localize());
            }
            if (CustomerProvider.QueryByEmail(request.Email) != null)
            {
                result.Errors.Add("The email already exists.".Localize());
            }
            if (string.IsNullOrEmpty(request.Password))
            {
                result.Errors.Add("Invalid password.".Localize());
            }
            #endregion

            if (result.Success)
            {
                var passwordSalt = PasswordEncryptor.GenerateSalt();
                var encryptedPwd = PasswordEncryptor.EncryptPassword(request.Password, passwordSalt);
                var customer     = new Customer()
                {
                    Username   = request.Username,
                    Email      = request.Email,
                    Membership = new Membership()
                    {
                        Password            = encryptedPwd,
                        PasswordSalt        = passwordSalt,
                        IsApproved          = request.IsApproved,
                        UtcCreationDate     = DateTime.UtcNow,
                        UtcLastActivityDate = DateTime.UtcNow
                    }
                };
                CustomerService.Add(customer);
            }

            return(result);
        }
Esempio n. 29
0
        public IActionResult ViewCustomersVehicles(string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Customer"] = CustomerProvider.getCustomerFromID(customerID);
            ViewData["Vehicles"] = CustomerProvider.getCustomerVehicles(customerID);

            return(View("ViewVehicles"));
        }
Esempio n. 30
0
        public IActionResult Search(string search)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Customers"] = CustomerProvider.searchCustomers(search);
            ViewData["Search"]    = search;

            return(View("View"));
        }
Esempio n. 31
0
        public int DeleteCustomer(int id)
        {
            CustomerProvider provider = new CustomerProvider();
            var obj = provider.GetCustomerById(id);

            if (obj != null)
            {
                provider.DeleteCustomer(obj);
                return(1);
            }
            return(-1);
        }