示例#1
0
        // DELETE: api/Sales/5
        public void Delete(Guid?id)
        {
            DatabaseTaskEntities context = new DatabaseTaskEntities();
            var result = context.Sales.Where(i => i.Id == id).FirstOrDefault();

            context.Sales.Remove(result);
            context.SaveChanges();
        }
示例#2
0
        // POST: api/Sales
        public Sales Post([FromBody] Sales obj)
        {
            DatabaseTaskEntities context = new DatabaseTaskEntities();

            context.Sales.Add(new Sales {
                Id = Guid.NewGuid(), Date = obj.Date, Price = obj.Price
            });
            context.SaveChanges();
            return(obj);
        }
示例#3
0
        // PUT: api/Sales/5
        public void Put(Guid?id, [FromBody] Sales obj)
        {
            DatabaseTaskEntities context = new DatabaseTaskEntities();
            var result = context.Sales.Where(i => i.Id == id).FirstOrDefault();

            if (obj.Price != null)
            {
                result.Price = obj.Price;
            }
            if (obj.Date != null)
            {
                result.Date = obj.Date;
            }
            context.SaveChanges();
        }