示例#1
0
        // get all offer region
        #region
        public List <GetAllOfferListModel> List()
        {
            AssignOfferInterface        assign = new AssignOfferInterface();
            List <GetAllOfferListModel> lst    = new List <GetAllOfferListModel>();

            var result = _entities.Nibs_Offer.ToList();

            foreach (var item in result)
            {
                GetAllOfferListModel model = new GetAllOfferListModel();
                var OfferName = assign.OfferName(item.OfferType);
                if (OfferName == "Combo Offer")
                {
                    model.ComboOfferList = GetComboOffer(item.OfferId);
                }
                else if (OfferName == "Amount Basis")
                {
                    model.BaseAmountList = GetAmountBasis(item.OfferId);
                }
                else if (OfferName == "Happy Hours")
                {
                    model.HappyHoursList = GetHappyHours(item.OfferId);
                }
                else
                {
                    model.BuyOfferList = GetBuyOffer(item.OfferId, OfferName);
                }

                lst.Add(model);
            }
            return(lst);
        }
示例#2
0
        // delete offer region
        #region
        public bool DeleteOffer(int OfferId)
        {
            try
            {
                AssignOfferInterface assign = new AssignOfferInterface();
                var assignOffer             = _entities.NIbs_AssignOffer.Where(a => a.OfferId == OfferId).SingleOrDefault();
                if (assignOffer == null)
                {
                    var result = _entities.Nibs_Offer.Where(a => a.OfferId == OfferId).SingleOrDefault();
                    foreach (var item in _entities.Nibs_Offer_Days.Where(a => a.OfferId == OfferId).ToList())
                    {
                        _entities.Nibs_Offer_Days.Remove(item);
                    }
                    _entities.SaveChanges();
                    foreach (var item in _entities.Nibs_Offer_Buy_Items.Where(a => a.OfferId == OfferId).ToList())
                    {
                        _entities.Nibs_Offer_Buy_Items.Remove(item);
                    }
                    _entities.SaveChanges();
                    foreach (var item in _entities.Nibs_Offer_Free_Items.Where(a => a.OfferId == OfferId).ToList())
                    {
                        _entities.Nibs_Offer_Free_Items.Remove(item);
                    }
                    _entities.SaveChanges();
                    var OfferName = assign.OfferName(result.OfferType);
                    if (OfferName == "Amount Basis")
                    {
                        foreach (var items in _entities.Nibs_Offer_Amount.Where(a => a.OfferId == OfferId).ToList())
                        {
                            _entities.Nibs_Offer_Amount.Remove(items);
                        }
                    }
                    _entities.SaveChanges();
                    if (OfferName == "Combo Offer")
                    {
                        foreach (var items in _entities.NIbs_ComboOffer.Where(a => a.OfferId == OfferId).ToList())
                        {
                            _entities.NIbs_ComboOffer.Remove(items);
                        }
                    }
                    _entities.SaveChanges();
                    _entities.Nibs_Offer.Remove(result);
                    _entities.SaveChanges();


                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#3
0
        public List <GetAllOfferListModel> List()
        {
            AssignOfferInterface        assign = new AssignOfferInterface();
            List <GetAllOfferListModel> list   = new List <GetAllOfferListModel>();
            var CurrentDay = DateTime.Now.DayOfWeek.ToString();
            var dayoffer   = entities.Nibs_Offer_Days.Where(a => a.Days.Contains(CurrentDay)).Select(a => a.OfferId).ToList();
            // XMLTablesRepository obj = new XMLTablesRepository();
            int OutletId = getOutletId();
            var result   = (from p in entities.Nibs_Offer
                            join q in entities.NIbs_AssignOffer
                            on p.OfferId equals q.OfferId
                            where q.UserId == OutletId &&
                            dayoffer.Contains(p.OfferId)
                            select new
            {
                OfferId = p.OfferId,
                OfferType = p.OfferType
            }).ToList();

            foreach (var item in result)
            {
                GetAllOfferListModel model = new GetAllOfferListModel();
                var OfferName = assign.OfferName(item.OfferType);
                if (OfferName == "Combo Offer")
                {
                    model.ComboOfferList = offer.GetComboOffer(item.OfferId);
                }
                else if (OfferName == "Amount Basis")
                {
                    model.BaseAmountList = offer.GetAmountBasis(item.OfferId);
                }
                else if (OfferName == "Happy Hours")
                {
                    model.HappyHoursList = offer.GetHappyHours(item.OfferId);
                }
                else
                {
                    model.BuyOfferList = offer.GetBuyOffer(item.OfferId, OfferName);
                }
                list.Add(model);
            }
            return(list);
        }
        public List <GetAllOfferListModel> List()
        {
            AssignOfferInterface        assign = new AssignOfferInterface();
            List <GetAllOfferListModel> list   = new List <GetAllOfferListModel>();
            int OutletId = obj.getOutletId();
            var result   = (from p in entities.Nibs_Offer
                            join q in entities.NIbs_AssignOffer
                            on p.OfferId equals q.OfferId
                            where q.UserId == OutletId
                            select new
            {
                OfferId = p.OfferId,
                OfferType = p.OfferType
            }).ToList();

            foreach (var item in result)
            {
                GetAllOfferListModel model = new GetAllOfferListModel();
                var OfferName = assign.OfferName(item.OfferType);
                if (OfferName == "Combo Offer")
                {
                    model.ComboOfferList = offer.GetComboOffer(item.OfferId);
                }
                else if (OfferName == "Amount Basis")
                {
                    model.BaseAmountList = offer.GetAmountBasis(item.OfferId);
                }
                else if (OfferName == "Happy Hours")
                {
                    model.HappyHoursList = offer.GetHappyHours(item.OfferId);
                }
                else
                {
                    model.BuyOfferList = offer.GetBuyOffer(item.OfferId, OfferName);
                }
                list.Add(model);
            }

            return(list);
        }