コード例 #1
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        public string SaveCustomer(SaveCustomer request)
        {
            if (request == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetCustomer request");
                LogError(ex);
                return("获得保存数据失败!");
            }
            CustomerAccessor accessor = new CustomerAccessor();
            Customer         customer = new Customer();

            customer.Code        = request.Code;
            customer.Name        = request.Name;
            customer.Description = request.Description;
            try
            {
                if (accessor.SaveCustomer(customer) == -1)
                {
                    return("项目名称在数据中已存在!");
                }
                else
                {
                    return("保存成功!");
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                return("保存失败!" + ex.Message);
            }
        }
コード例 #2
0
        public Customer AuthenticateLogin(string email, string password)
        {
            Customer _customer = null;

            try
            {
                string pwhash = HashSHA256(password);
                if (1 == CustomerAccessor.VerifyLoginInfo(email, pwhash))
                {
                    password = null;

                    _customer = CustomerAccessor.RetrieveCustomerWithEmail(email);
                }
                else
                {
                    throw new ApplicationException("An error has occurred.");
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Incorrect email or password.");
            }

            return(_customer);
        }
コード例 #3
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        public Response <Customer> DeleteCustomer(long ID)
        {
            CustomerAccessor    accessor = new CustomerAccessor();
            Response <Customer> response = new Response <Customer>();

            try
            {
                if (accessor.DeleteCustomer(ID))
                {
                    response.IsSuccess      = true;
                    response.SuccessMessage = "删除成功!";
                }
                else
                {
                    response.IsSuccess = false;
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess      = false;
                response.SuccessMessage = "删除失败!" + ex.Message;
            }
            return(response);
        }
コード例 #4
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        /// <summary>
        /// 货主客户新增编辑
        /// </summary>
        public Response <IEnumerable <Customer> > AddCustomer(AddCustomerRequest request, string ID, string UserName, int projectId, int segmentId)
        {
            Response <IEnumerable <Customer> > response = new Response <IEnumerable <Customer> >();

            if (request == null || request.customers == null)
            {
                ArgumentNullException ex = new ArgumentNullException("AddCustomer request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                CustomerAccessor accessor = new CustomerAccessor();
                response.Result    = accessor.AddCustomers(request.customers, ID, UserName, projectId, segmentId);
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
コード例 #5
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        public Response <GetCustomerByConditionResponse> GetCustomerByConditon(GetCustomerByConditionRequest request)
        {
            Response <GetCustomerByConditionResponse> response = new Response <GetCustomerByConditionResponse>()
            {
                Result = new GetCustomerByConditionResponse()
            };

            if (request == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetCustomerByConditon request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                CustomerAccessor accessor = new CustomerAccessor();
                int rowCount;
                response.Result.Customer  = accessor.GetCustomerByConditon(request.Code, request.Name, request.UserId, request.ProjectId, request.StoreType, request.State, request.PageIndex, request.PageSize, out rowCount);
                response.Result.PageIndex = request.PageIndex;
                response.Result.PageCount = rowCount % request.PageSize == 0 ? rowCount / request.PageSize : rowCount / request.PageSize + 1;
                response.IsSuccess        = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
コード例 #6
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        public Response <Customer> GetCustomerInfo(GetCustomerByCustomerIdRequest request)
        {
            Response <Customer> response = new Response <Customer>();

            if (request == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetCustomerInfo request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            CustomerAccessor accessor = new CustomerAccessor();

            try
            {
                response.Result    = accessor.GetCustomerById(request.CustomerID);
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
コード例 #7
0
        /// <summary>
        /// Eric Walton
        /// 2017/26/02
        /// Retrieves a list of all commercial customers
        /// If succesful returns list
        /// If unsuccesful throws error
        ///
        /// Update
        /// Bobby Thorne
        /// 5/7/2017
        /// Adds an ApprovedByName to the CommercailCustomer
        /// To fill the datagrid.
        /// </summary>
        /// <returns></returns>
        public List <CommercialCustomer> RetrieveCommercialCustomers()
        {
            List <CommercialCustomer> commercialCustomers = null;

            try
            {
                UserManager     userManager     = new UserManager();
                EmployeeManager employeeManager = new EmployeeManager();
                commercialCustomers = CustomerAccessor.RetrieveAllCommercialCustomers();
                foreach (CommercialCustomer e in commercialCustomers)
                {
                    e.name = userManager.RetrieveUser(e.UserId).LastName + ", " + userManager.RetrieveUser(e.UserId).FirstName;
                    if (e.ApprovedBy != null)
                    {
                        var approvalUser = userManager.RetrieveUser(e.ApprovedBy);
                        if (approvalUser.FirstName.Equals("") && approvalUser.LastName.Equals(""))
                        {
                            e.ApprovedByName = "";
                        }
                        else
                        {
                            e.ApprovedByName = approvalUser.LastName + ", " + approvalUser.FirstName;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(commercialCustomers);
        }
コード例 #8
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
 public Customer selectCustomer(int id)
 {
     try
     {
         CustomerAccessor accessor = new CustomerAccessor();
         return(accessor.selectCustomer(id));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #9
0
        public static AccessToken LogInUser(Customer customer)
        {
            AccessToken accessToken = new AccessToken();

            accessToken.User = customer;

            var roles = CustomerAccessor.RetrieveRolesByUserID(customer.CustomerID);

            accessToken.Roles = roles;

            return(accessToken);
        }
コード例 #10
0
        public static bool ValidateNewUser(string username, string newPassword)
        {
            if (1 == CustomerAccessor.FindUserByUsernameAndPassword(username, "password"))
            {
                CustomerAccessor.SetPasswordForUsername(username, "password", newPassword.HashSha256());
            }
            else
            {
                throw new ApplicationException("New user could not be created.");
            }

            return(ValidateExistingUser(username, newPassword));
        }
コード例 #11
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        public string UpdateCustomer(Customer customer)
        {
            CustomerAccessor accessor = new CustomerAccessor();

            try
            {
                return(accessor.UpdateCustomer(customer) == -1 ? "项目名称在数据中已存在!" : "保存成功!");
            }
            catch (Exception ex)
            {
                LogError(ex);
                return("保存失败!" + ex.Message);
            }
        }
コード例 #12
0
        /// <summary>
        /// Eric Walton
        /// 2017/06/02
        ///
        /// Create Commercial Account method
        /// Trys to create a commercial account
        /// If successful it returns true
        /// If unsuccessful it returns false
        /// </summary>
        /// <param name="commercialCustomer"></param>
        /// <returns></returns>
        public bool CreateCommercialAccount(CommercialCustomer commercialCustomer)
        {
            bool result = false;

            try
            {
                result = 1 == CustomerAccessor.CreateCommercialCustomer(commercialCustomer);
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
コード例 #13
0
        public bool UpdateCustomerPassword(int?customerID, string oldPassword, string newPassword)
        {
            var result = false;

            try
            {
                result = (1 == CustomerAccessor.UpdateCustomerPasswordHash(customerID, oldPassword, newPassword));
            }
            catch (Exception ex)
            {
                throw new Exception("Something went wrong. Password not updated." + ex.Message + ex.StackTrace);
            }
            return(result);
        }
コード例 #14
0
        public Customer RetrieveCustomerByID(int?id)
        {
            Customer _customer = null;

            try
            {
                _customer = CustomerAccessor.RetrieveCustomerWithID(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(_customer);
        }
コード例 #15
0
        public int?RetrieveCustomerIdByEmail(string email)
        {
            int?id = 0;

            try
            {
                id = CustomerAccessor.RetrieveCustomerWithEmail(email).CustomerID;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(id);
        }
コード例 #16
0
        public bool CreateCustomerAccount(string firstName, string lastName, string phoneNum,
                                          string zip, string email)
        {
            var result = false;

            try
            {
                result = (1 == CustomerAccessor.AddNewCustomer(firstName, lastName, phoneNum, zip, email));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return(result);
        }
コード例 #17
0
        public bool UpdateCustomerEmail(int?customerID, string email)
        {
            var result = false;

            try
            {
                result = (1 == CustomerAccessor.UpdateCustomerEmail(customerID, email));
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred updating email" + ex.Message);
            }

            return(result);
        }
コード例 #18
0
        public List <Customer> CurrentCustomers(bool active)
        {
            List <Customer> customers = null;

            try
            {
                customers = CustomerAccessor.RetrieveCurrentCustomers(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("An error occurred loading current customers list" + ex.StackTrace);
            }

            return(customers);
        }
コード例 #19
0
        public bool IsUserStaff(string username)
        {
            bool isStaff = false;

            try
            {
                isStaff = CustomerAccessor.IsCustomerStaff(username);
            }
            catch (Exception)
            {
                throw;
            }

            return(isStaff);
        }
コード例 #20
0
        public List <Comic> OrderFormForCustomer(int?customerID)
        {
            List <Comic> _comics = new List <Comic>();

            try
            {
                _comics = CustomerAccessor.RetrieveCustomerOrder(customerID);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Your order form of comics was not found." + ex.Message + ex.StackTrace);
            }

            return(_comics);
        }
コード例 #21
0
 /// <summary>
 /// Bobby Thorne
 /// 4/7/2017
 ///
 /// Calls the accessor method to denie Commercial Customers and updates who made the change
 /// </summary>
 /// <param name="commercialCustomer"></param>
 /// <param name="approvedBy"></param>
 /// <returns></returns>
 public bool DenyCommercialCustomer(CommercialCustomer commercialCustomer, int approvedby)
 {
     try
     {
         if (CustomerAccessor.DenyCommercialCustomer(commercialCustomer, approvedby) > 0)
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(false);
 }
コード例 #22
0
        /// <summary>
        /// Deletes the customer.
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool DeleteCustomer(Customer customer)
        {
            int count = 0;

            count = CustomerAccessor.DeleteCustomer(customer.CustomerID);

            if (count >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #23
0
        public List <Comic> PullListForCustomer(int?customerID)
        {
            List <Comic> _comics = new List <Comic>();

            try
            {
                _comics = CustomerAccessor.RetrieveCustomerPull(customerID);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Pull list of comics not found." + ex.Message + ex.StackTrace);
            }

            return(_comics);
        }
コード例 #24
0
        public List <Customer> CurrentCustomersList()
        {
            List <Customer> customers = null;

            try
            {
                customers = CustomerAccessor.RetrieveCurrentCustomers(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("A problem occurred loading this list of current customers" + ex.Message);
            }

            return(customers);
        }
コード例 #25
0
        public List <Customer> DeactivatedCustomersList()
        {
            List <Customer> customers = null;

            try
            {
                customers = CustomerAccessor.RetrieveDeactivatedCustomers(false);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("A problem occurred loading this list of current customers" + ex.StackTrace);
            }

            return(customers);
        }
コード例 #26
0
        public bool CheckUserName(string username)
        {
            try
            {
                if (CustomerAccessor.CheckUserName(username) == 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
コード例 #27
0
        public static bool ValidateExistingUser(string username, string password)
        {
            bool valid = false;

            try
            {
                if (1 == CustomerAccessor.FindUserByUsernameAndPassword(username, password.HashSha256()))
                {
                    valid = true;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(valid);
        }
コード例 #28
0
 /// <summary>
 /// Updates the customer.
 /// </summary>
 /// <param name="customer">The customer.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public bool UpdateCustomer(Customer customer)
 {
     try
     {
         if (CustomerAccessor.UpdateCustomer(customer) >= 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #29
0
        public bool AddCustomer(Customer customer)
        {
            customer.Password = customer.Password.HashSha256();

            try
            {
                if (CustomerAccessor.InsertCustomer(customer))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw new ApplicationException("User could not be added");
            }

            return(false);
        }
コード例 #30
0
ファイル: CustomerService.cs プロジェクト: ChainSong/WMS
        /// <summary>
        /// 验证公司编号 唯一性
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public string CheckNameIsExist(string Name, int?Id, string ProjectID, bool IsEdit)
        {
            CustomerAccessor accessor    = new CustomerAccessor();
            string           ReturnValue = string.Empty;

            try
            {
                if (!accessor.CheckNameIsExist(Name, Id, ProjectID, IsEdit))
                {
                    ReturnValue = "该客户名称已存在!";
                }
            }
            catch (Exception ex)
            {
                ReturnValue = ex.Message;
                LogError(ex);
            }
            return(ReturnValue);
        }