Beispiel #1
0
        public ApiMessage <string> Save(instore model)
        {
            var api = new ApiMessage <string>();

            model.UnitName = model.UnitID;
            model.ID       = Guid.NewGuid().ToString();
            using (var scope = new PetaPoco.Transaction(_db))
            {
                var sModel = _db.FirstOrDefault <store>("where ProductID=@ProductID AND UnitID=@UnitID", model);
                if (sModel == null)
                {
                    sModel             = new store();
                    sModel.Amount      = model.Amount;
                    sModel.ProductID   = model.ProductID;
                    sModel.ProductName = model.ProductName;
                    sModel.UnitID      = model.UnitID;
                    sModel.UnitName    = model.UnitID;
                    sModel.UpdateDate  = DateTime.Now;
                    sModel.CreateDate  = DateTime.Now;
                    sModel.ID          = Guid.NewGuid().ToString();
                    sModel.OutAmount   = 0;
                    sModel.OutAmount   = 0;
                    _db.Insert(sModel);
                }
                else
                {
                    sModel.Amount = sModel.Amount + model.Amount;
                    _db.Update(sModel);
                }
                _db.Insert(model);
                scope.Complete();
            }
            return(api);
        }
Beispiel #2
0
        public JsonResult Save(instore model)
        {
            model.StaffID    = UserInfo.Id;
            model.StaffName  = UserInfo.UserName;
            model.CreateDate = DateTime.Now;

            var res = _proBll.Save(model);

            return(Json(res));
        }
Beispiel #3
0
 public ApiMessage <string> Save(instore model)
 {
     return(_dal.Save(model));
 }