Пример #1
0
        public void Write(RestaurantInformation objectToList, string fileName)
        {
            SocialTapContext db = new SocialTapContext();

            db.RestaurantInformationTable.Add(objectToList);
            db.SaveChanges();
        }
Пример #2
0
        public void Write(Drink objectToList)
        {
            SocialTapContext db = new SocialTapContext();

            db.DrinkInfo.Add(objectToList);
            db.SaveChanges();
        }
Пример #3
0
        public IHttpActionResult Post(Restaurant restaurant)
        {
            SocialTapContext context = new SocialTapContext();

            context.Restaurants.Add(restaurant);
            context.SaveChanges();
            return(Ok());
        }
Пример #4
0
        public IHttpActionResult Post(RestaurantScan scan)
        {
            var list = context.Restaurants.Where(t => t.placesId == scan.Place_Id).Take(1).ToList();

            if (list.Count == 0)
            {
                Restaurant res = new Restaurant();
                res.placesId = scan.Place_Id;
                res.Name     = scan.Name;
                res.Address  = scan.Address;
                res.Sum      = scan.Percentage;
                res.Times    = 1;
                context.Restaurants.Add(res);
                context.SaveChanges();
                Scan scans = new Scan();
                var  lista = context.Users.ToList().Where(x => x.Id == "897b973b-0050-4474-8e7c-858a3f53f2d2");
                scans.SocialTapUser = lista.First();
                scans.Date          = DateTime.Today;
                scans.Percentage    = scan.Percentage;
                scans.Millimeters   = scan.Millimeters;
                scans.Drink         = scan.Drink;
                scans.Price         = scan.Price;
                scans.Restaurant    = res;
                context.Scans.Add(scans);
                context.SaveChanges();
            }
            else
            {
                list.ElementAt(0).Times += 1;
                list.ElementAt(0).Sum   += scan.Percentage;
                context.SaveChanges();
                Scan scans = new Scan();
                var  lista = context.Users.ToList().Where(x => x.Id == "897b973b-0050-4474-8e7c-858a3f53f2d2");
                scans.SocialTapUser = lista.First();
                scans.Date          = DateTime.Today;
                scans.Millimeters   = scan.Millimeters;
                scans.Drink         = scan.Drink;
                scans.Percentage    = scan.Percentage;
                scans.Price         = scan.Price;
                scans.Restaurant    = list.ElementAt(0);
                context.Scans.Add(scans);
                context.SaveChanges();
            }
            return(Ok());
        }
Пример #5
0
        public IHttpActionResult Post(New news)
        {
            var list = context.Users.ToList().Where(x => x.Id == System.Web.HttpContext.Current.User.Identity.GetUserId());

            news.SocialTapUser = list.First();
            context.News.Add(news);
            context.SaveChanges();
            return(Ok());
        }
Пример #6
0
        public IHttpActionResult Get()
        {
            var scans = context.Scans.ToList();

            foreach (Scan scan in scans)
            {
                if (DateTime.Compare(scan.Date.AddDays(30), DateTime.Today) < 0)
                {
                    context.Scans.Remove(scan);
                    context.SaveChanges();
                }
            }
            return(Ok());
        }
Пример #7
0
        public IHttpActionResult Get()
        {
            SocialTapContext context = new SocialTapContext();
            Scan             sc      = new Scan();

            sc.Date        = DateTime.Today.AddDays(-15);
            sc.Drink       = "Alcohol";
            sc.Percentage  = 33;
            sc.Millimeters = 870;
            sc.Price       = 5.80;
            var d = context.Restaurants.ToList();

            sc.Restaurant = d.ElementAt(0);
            //REIKIA DABARTINIO USERIO
            var list = context.Users.ToList();

            sc.SocialTapUser = list.ElementAt(0);
            //**************************************
            context.Scans.Add(sc);
            context.SaveChanges();
            var result = _rep.GetAll();

            return(Ok(result));
        }
Пример #8
0
 public void Write(New newToFile)
 {
     _db.NewTable.Add(newToFile);
     _db.SaveChanges();
 }