Ejemplo n.º 1
0
 public ProductitemInfo Save()
 {
     if (this.Id != null)
     {
         Productitem.Update(this);
         return(this);
     }
     return(Productitem.Insert(this));
 }
Ejemplo n.º 2
0
        public APIReturn _Add([FromForm] uint?Product_id, [FromForm] string Img_url, [FromForm] IFormFile Img_url_file, [FromForm] string Name, [FromForm] decimal?Original_price, [FromForm] decimal?Price, [FromForm] uint?Stock)
        {
            ProductitemInfo item = new ProductitemInfo();

            if (Img_url_file != null)
            {
                item.Img_url = $"/upload/{Guid.NewGuid().ToString()}.png";
                using (FileStream fs = new FileStream(System.IO.Path.Combine(AppContext.BaseDirectory, item.Img_url), FileMode.Create)) Img_url_file.CopyTo(fs);
            }
            else
            {
                item.Img_url = Img_url;
            }
            item.Product_id     = Product_id;
            item.Name           = Name;
            item.Original_price = Original_price;
            item.Price          = Price;
            item.Stock          = Stock;
            item = Productitem.Insert(item);
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Ejemplo n.º 3
0
 public ProductitemInfo AddProductitem(string Img_url, string Name, decimal?Original_price, decimal?Price, uint?Stock) => Productitem.Insert(new ProductitemInfo {
     Product_id     = this.Id,
     Img_url        = Img_url,
     Name           = Name,
     Original_price = Original_price,
     Price          = Price,
     Stock          = Stock
 });