Example #1
0
 public ICollection <TabelaPreco> Get()
 {
     using (var context = new WebServiceDBContext())
     {
         return(context.TabelaPrecos.ToList());
     }
 }
Example #2
0
 public ICollection <TypeProduct> Get()
 {
     using (var context = new WebServiceDBContext())
     {
         return(context.TypeProduct.ToList());
     }
 }
Example #3
0
 public void Post([FromBody] TypeProduct tp)
 {
     using (var context = new WebServiceDBContext())
     {
         context.TypeProduct.Add(tp);
         context.SaveChanges();
     }
 }
Example #4
0
 public void Put([FromBody] TypeProduct tp)
 {
     using (var context = new WebServiceDBContext())
     {
         context.Entry(tp).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #5
0
 public void Post([FromBody] Product p)
 {
     using (var context = new WebServiceDBContext())
     {
         context.Produtcs.Add(p);
         context.SaveChanges();
     }
 }
Example #6
0
 public void Put([FromBody] TabelaPreco tb)
 {
     using (var context = new WebServiceDBContext())
     {
         context.Entry(tb).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #7
0
 public List <Notice> GetNoticeList()
 {
     using (var db = new WebServiceDBContext(_configuration))
     {
         return(db.Notices
                .OrderByDescending(n => n.NoticeNo)
                .ToList());
     }
 }
Example #8
0
 /// <summary>
 /// 1. 리뷰 목록
 /// </summary>
 /// <returns></returns>
 public List <Review> GetReviewList()
 {
     using (var db = new WebServiceDBContext(_configuration))
     {
         return(db.Reviews
                .OrderByDescending(n => n.ReviewNo)
                .ToList());
     }
 }
Example #9
0
        public Product Get(long id)
        {
            Product prod = null;

            using (var context = new WebServiceDBContext())
            {
                prod = context.Produtcs.Find(id);
            }

            return(prod);
        }
Example #10
0
        public TabelaPreco Get(long id)
        {
            TabelaPreco tb = null;

            using (var context = new WebServiceDBContext())
            {
                tb = context.TabelaPrecos.Find(id);
            }

            return(tb);
        }
Example #11
0
        public TypeProduct Get(long id)
        {
            TypeProduct tp = null;

            using (var context = new WebServiceDBContext())
            {
                tp = context.TypeProduct.Find(id);
            }

            return(tp);
        }
Example #12
0
        public HttpResponseMessage Delete(long id)
        {
            using (var context = new WebServiceDBContext())
            {
                TypeProduct tp = context.TypeProduct.Find(id);

                context.Entry(tp).State = System.Data.Entity.EntityState.Deleted;
                context.SaveChanges();
            }

            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }
Example #13
0
        public void Post([FromBody] TabelaPreco tp)
        {
            using (var context = new WebServiceDBContext())
            {
                foreach (Product p in tp.producs)
                {
                    context.Produtcs.Attach(p);
                    context.Entry(p).State = System.Data.Entity.EntityState.Unchanged;
                }

                context.TabelaPrecos.Add(tp);
                context.SaveChanges();
            }
        }
        public void GenerateFiveRandomSummaries()
        {
            // Arrange
            var builder = new DbContextOptionsBuilder <WebServiceDBContext>();

            builder.UseSqlServer("Data Source = (localdb)\\MSSQLLocalDB; Initial Catalog = WeatherForecaster");

            using (var dbContext = new WebServiceDBContext(builder.Options))
            {
                var forecaster = new WeatherForecaster(dbContext);

                // Act
                var weatherSummaries = forecaster.WeatherSummaires();

                // Assert
                Assert.IsTrue(weatherSummaries.Length == 5);
            };
        }
        //[TestMethod]
        public void GetFiveSummariesFromDatabase()
        {
            // Arrange
            var builder = new DbContextOptionsBuilder <WebServiceDBContext>();

            builder.UseSqlServer("Data Source = (localdb)\\MSSQLLocalDB; Initial Catalog = WeatherForecaster");

            using (var dbContext = new WebServiceDBContext(builder.Options))
            {
                var forecaster = new WeatherForecaster(dbContext);

                // Act
                var weatherSummaries = forecaster.WeatherSummariesFromDatabase().Result;

                // Assert
                Assert.IsTrue(weatherSummaries.Count == 5);
            };
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeatherForecaster"/> class.
 /// </summary>
 /// <param name="context">DBContext.</param>
 public WeatherForecaster(WebServiceDBContext context)
 {
     _dbContext = context;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneralContactsService"/> class.
 /// </summary>
 /// <param name="context">DBContext.</param>
 public GeneralContactsService(WebServiceDBContext context)
 {
     _dbContext = context;
 }