示例#1
0
        public List <AdvertisingDto> GetAdvertising(List <string> tags)
        {
            List <AdvertisingDto> Advertising = new List <AdvertisingDto>();
            int num = 0;

            foreach (string tag in tags)
            {
                List <AdvertisingEntity> FulList = (List <AdvertisingEntity>)FactorySingleton.GetDal().Dal.Advertising().GetByFieldName("type", tag);
                if (FulList.Count != 0 && num < 3)
                {
                    foreach (var el in FulList)
                    {
                        Advertising.Add(new AdvertisingDto(el.Purchase, el.Cost, el.Type, el.Info, el.Picture));
                        num += 1;
                        if (num == 3)
                        {
                            break;
                        }
                    }
                }
            }
            if (Advertising.Count != 0)
            {
                while (num < 3)
                {
                    Advertising.Add(Advertising[0]);
                    num += 1;
                }
                return(Advertising);
            }
            else
            {
                return(Advertising);
            }
        }
示例#2
0
        public int SignUp(UserDto InfoDto)
        {
            long id = -1;

            try
            {
                FactorySingleton.GetDal().Dal.User().Insert(new UserEntity(InfoDto.Nickname, GetMD5(InfoDto.Password)));
                id = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", InfoDto.Nickname)[0].ID.Value;
                FactorySingleton.GetDal().Dal.Person().Insert(new PersonEntity(id, InfoDto.Name, InfoDto.Surname, InfoDto.PhoneNumber.Value, InfoDto.BornDate, InfoDto.Address));
                FactorySingleton.GetDal().Dal.SpecialQuestion().Insert(new SpecialQuestionEntity(id, InfoDto.Question, InfoDto.Answer));
                return(1);
            }
            catch
            {
                if (id != -1)
                {
                    if (FactorySingleton.GetDal().Dal.User().GetById(id) != null)
                    {
                        FactorySingleton.GetDal().Dal.SpecialQuestion().DeleteById(id);

                        FactorySingleton.GetDal().Dal.Person().DeleteById(id);

                        FactorySingleton.GetDal().Dal.User().DeleteById(id);
                    }
                }

                return(0);
            }
        }
示例#3
0
        public List <AdvertisingDto> GetAdvertising()
        {
            int num = 0;
            List <AdvertisingDto>    Advertising = new List <AdvertisingDto>();
            List <AdvertisingEntity> FulList     = (List <AdvertisingEntity>)FactorySingleton.GetDal().Dal.Advertising().GetAll();

            if (FulList.Count != 0)
            {
                foreach (var el in FulList)
                {
                    Advertising.Add(new AdvertisingDto(el.Purchase, el.Cost, el.Type, el.Info, el.Picture));
                    num += 1;
                    if (num == 3)
                    {
                        break;
                    }
                }
                while (num < 3)
                {
                    Advertising.Add(Advertising[0]);
                    num += 1;
                }
                return(Advertising);
            }
            else
            {
                return(Advertising);
            }
        }
        public PurchaseHistoryBll(string nickname)
        {
            this.nickname = nickname;
            user_id       = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname)[0].ID.Value;
            HistoryList   = new List <PurchaseHistoryDto>();

            ClearSortAndFilters();
        }
示例#5
0
 public bool LoginIsFree(string nickname)
 {
     if (FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname).Count > 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        //Private
        private List <PurchaseHistoryDto> GetFullList()
        {
            List <PurchaseHistoryDto>    FullList    = new List <PurchaseHistoryDto>();
            List <PurchaseHistoryEntity> Historylist = (List <PurchaseHistoryEntity>)FactorySingleton.GetDal().Dal.PurchaseHistory().GetByFieldName("id", user_id);

            foreach (var el in Historylist)
            {
                ProductEntity Product = FactorySingleton.GetDal().Dal.Product().GetById(el.ProductID.Value);
                FullList.Add(new PurchaseHistoryDto(Product.Name, Product.Cost.Value, Product.Type, Product.Brand, nickname, el.Date));
            }
            return(FullList);
        }
示例#7
0
 public string GetSpesialQuestion(string nickname)// 1 user get question, set answer
 {
     try
     {
         UserEntity UEntity = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname)[0];
         return(FactorySingleton.GetDal().Dal.SpecialQuestion().GetById(UEntity.ID.Value).Question);
     }
     catch
     {
         return("");
     }
 }
 public int Delete(PurchaseHistoryDto Dto)
 {
     try
     {
         int x = FactorySingleton.GetDal().Dal.PurchaseHistory().Delete(new PurchaseHistoryEntity
                                                                            (user_id, FactorySingleton.GetDal().Dal.Product().GetByFieldName("name", Dto.Name)[0].ID.Value, Dto.Date));
         FactorySingleton.GetDal().Dal.Product().DeleteByFieldName("id", FactorySingleton.GetDal().Dal.Product().GetByFieldName("name", Dto.Name)[0].ID.Value);
         return(x);
     }
     catch
     {
         return(0);
     }
 }
        public int Add(PurchaseHistoryDto Dto)
        {
            try
            {
                FactorySingleton.GetDal().Dal.Product().Insert(new ProductEntity(Dto.Name, Dto.Cost.Value, Dto.Brand, Dto.Brand));
                FactorySingleton.GetDal().Dal.PurchaseHistory().Insert(
                    new PurchaseHistoryEntity(user_id, FactorySingleton.GetDal().Dal.Product().GetByFieldName("name", Dto.Name)[0].ID.Value, DateTime.Now));

                return(1);
            }
            catch
            {
                return(0);
            }
        }
 public int Edit(PurchaseHistoryDto Dto, string productOldName)
 {
     try
     {
         FactorySingleton.GetDal().Dal.Product().UpdateByEntity(new ProductEntity(Dto.Name, Dto.Cost.Value, Dto.Type, Dto.Brand)
         {
             ID = FactorySingleton.GetDal().Dal.Product().GetByFieldName("name", productOldName)[0].ID.Value
         });
         return(1);
     }
     catch
     {
         return(0);
     }
 }
示例#11
0
        public Parser(Environment.Environment environment)
        {
            // Language elements
            DFBAB["break"] = new FactorySingleton <Input, IBatchable>(new BatchBreaker());

            // Keywords
            DFBAB["use"] = new Language.Use(this, environment);
            DFBAB["run"] = new Language.Run(this, environment);

            // Commands
            DFBAB["exe"]     = new lg(environment, lg.Create_Exe);
            DFBAB["set"]     = new lg(environment, lg.Create_Set);
            DFBAB["display"] = new lg(environment, lg.Create_Display);
            DFBAB["http"]    = new lg(environment, Web.CmdRequestHttp.Create);
        }
        public int GetFilteredByBradList(string brand)
        {
            List <PurchaseHistoryEntity> Historylist = (List <PurchaseHistoryEntity>)FactorySingleton.GetDal().Dal.PurchaseHistory().GetByFieldName("id", user_id);

            foreach (var el in Historylist)
            {
                HistoryList.Clear();
                ProductEntity Product = FactorySingleton.GetDal().Dal.Product().GetById(el.ProductID.Value);
                if (Product.Brand == brand)
                {
                    HistoryList.Add(new PurchaseHistoryDto(Product.Name, Product.Cost.Value, Product.Type, Product.Brand, nickname, el.Date));
                }
            }
            return(HistoryList.Count);
        }
示例#13
0
 public int ChangePassword(string nickname, string answer, string newPassword) //3 change password
 {
     try
     {
         if (CompareAnswer(answer, nickname))
         {
             UserEntity UEntity = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname)[0];
             FactorySingleton.GetDal().Dal.User().UpdateByFieldName("password", GetMD5(newPassword), "id", UEntity.ID.Value);
             return(1);
         }
         return(0);
     }
     catch
     {
         return(0);
     }
 }
示例#14
0
 public UserDto SignIn(string nickname, string password)
 {
     try
     {
         UserEntity UEntity = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname)[0];
         if (UEntity.Password == GetMD5(password))
         {
             PersonEntity          PEntity  = FactorySingleton.GetDal().Dal.Person().GetById(UEntity.ID.Value);
             SpecialQuestionEntity SQEntity = FactorySingleton.GetDal().Dal.SpecialQuestion().GetById(UEntity.ID.Value);
             return(new UserDto(UEntity.Nickname, UEntity.Password, PEntity.Name, PEntity.Surname, PEntity.PhoneNumber.Value, PEntity.BornDate, PEntity.Address, SQEntity.Question, SQEntity.Answer));
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
示例#15
0
        public bool CompareAnswer(string answer, string nickname) //2 if true change password
        {
            UserEntity UEntity = FactorySingleton.GetDal().Dal.User().GetByFieldName("nickname", nickname)[0];

            return(FactorySingleton.GetDal().Dal.SpecialQuestion().GetById(UEntity.ID.Value).Answer == answer);
        }