Exemple #1
0
        public IDPaperInfo GetUserByIDPaper(string content)
        {
            IDPaperInfo iDPaperInfo = null;
            Idpaper     idpaper     = null;

            string[] contents = content.Split(" ");
            foreach (string con in contents)
            {
                idpaper = _iDPaperRepository.GetAll().Where(ip => ip.Content == con).FirstOrDefault();
                if (idpaper != null)
                {
                    break;
                }
            }

            //Idpaper idpaper = _iDPaperRepository.GetAll().Where(ip => ip.Content.ToLower().Contains(content)).FirstOrDefault();
            if (idpaper != null)
            {
                iDPaperInfo = new IDPaperInfo()
                {
                    UserId       = idpaper.CustomerId,
                    AppliedPrice = idpaper.AppliedPrice
                };
            }

            return(iDPaperInfo);
        }
Exemple #2
0
        public bool RegisterIDPaper(string type, string content, int customerId)
        {
            var result = false;
            //Check if paper is registed?
            Idpaper idpaper = _iDPaperRepository.GetAll().Where(ip => ip.CustomerId == customerId && ip.Content.Contains(content)).FirstOrDefault();

            if (idpaper == null)
            {//If paper is not registered
                idpaper = new Idpaper()
                {
                    CustomerId   = customerId,
                    Content      = content,
                    AppliedPrice = GetPriceByType(type),
                    IsUsing      = true,
                    IsValid      = true,
                    Type         = type
                };
                idpaper = _iDPaperRepository.Add(idpaper);
                if (idpaper != null)
                {
                    result = true;
                }
            }

            return(result);
        }
Exemple #3
0
        public bool ChangeState(int id, bool isActive)
        {
            Idpaper idpaper = _iDPaperRepository.GetById(id);

            if (idpaper == null)
            {
                return(false);
            }
            idpaper.IsUsing = isActive;
            _iDPaperRepository.Update(idpaper);
            return(true);
        }
Exemple #4
0
        public bool DeleteIDPaper(int id)
        {
            bool    result  = false;
            Idpaper idpaper = _iDPaperRepository.GetById(id);

            if (idpaper != null)
            {
                _iDPaperRepository.Delete(idpaper);
                result = true;
            }

            return(result);
        }
Exemple #5
0
        public IDPaperInfo VerifyIDPaper(string input)
        {
            IDPaperInfo result = null;

            string[] inputs  = input.Split(" ");
            Idpaper  idpaper = _iDPaperRepository.GetAll().Where(ip => inputs.Any(val => ip.Content.Contains(val))).FirstOrDefault();

            if (idpaper != null)
            {
                if (!idpaper.IsValid)
                {
                    result = new IDPaperInfo()
                    {
                        Type         = IDPaperConstants.IDPP_INVALID,
                        UserId       = idpaper.CustomerId,
                        AppliedPrice = 0
                    };
                }
                else if (!idpaper.IsUsing)
                {
                    result = new IDPaperInfo()
                    {
                        Type         = IDPaperConstants.IDPP_INACTIVE,
                        UserId       = idpaper.CustomerId,
                        AppliedPrice = 0
                    };
                }
                else
                {
                    result = new IDPaperInfo()
                    {
                        Type         = idpaper.Type,
                        UserId       = idpaper.CustomerId,
                        AppliedPrice = idpaper.AppliedPrice
                    };
                }
            }

            return(result);
        }