示例#1
0
        public IHttpActionResult PutCustomer(int id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            db.Entry(customer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult PutItem(int id, Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != item.ItemId)
            {
                return(BadRequest());
            }

            db.Entry(item).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public ActionResult CreateStock()
        {
            LearningEntities DB    = new LearningEntities();
            Stock            stock = new Stock();
            string           imgUrl;

            string formUrl = this.Request.Form[0];
            string dataUrl = this.Request.Form[1];

            formUrl = Server.UrlDecode(formUrl);

            if (string.IsNullOrEmpty(dataUrl))
            {
                return(Content("图片不为空"));
            }
            else
            {
                imgUrl = UpImg(dataUrl);
            }

            char[]   c    = new char[] { '&', '=' };
            string[] form = formUrl.Split(c);
            for (int i = 0; i < form.Length; i += 2)
            {
                if (form[i] == "mingcheng")
                {
                    stock.Sname = form[i + 1]; continue;
                }
                else if (form[i] == "jiage")
                {
                    stock.SPrice = form[i + 1]; continue;
                }
                else if (form[i] == "num")
                {
                    stock.Snum = form[i + 1]; continue;
                }
                else if (form[i] == "bz")
                {
                    stock.SComment = form[i + 1]; continue;
                }
            }

            string id = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

            stock.StockId   = id;
            stock.SSaveDate = DateTime.Now;
            stock.SImgUrl   = imgUrl;
            DB.Stock.AddObject(stock);
            DB.SaveChanges();
            return(Content("入库成功"));
        }
示例#4
0
        public ActionResult Borrow()
        {
            LearningEntities DB = new LearningEntities();
            Log log             = new Log();

            log.Person = this.Request.Params["Person"];
            log.ItemId = Convert.ToInt32(this.Request.Params["ItemId"]);
            log.Num    = Convert.ToInt32(this.Request.Params["ItemNum"]);
            log.Time   = DateTime.Now;
            DB.Log.AddObject(log);

            int itemnum = (int)DB.Item.FirstOrDefault(i => i.Id == log.ItemId).Num;

            DB.Item.FirstOrDefault(i => i.Id == log.ItemId).Num = itemnum - log.Num;
            DB.SaveChanges();


            return(null);
        }
示例#5
0
 public void Save()
 {
     context.SaveChanges();
 }