Example #1
0
        public IHttpActionResult Post([FromBody] Productdesc productdesc)
        {
            int    Result;
            string extension, myimage;
            int    imagenumber  = 1;
            Image  productimage = new Image();
            var    userid       = User.Identity.GetUserId();
            var    c            = db.Companies.FirstOrDefault(a => a.userid == userid);

            if (ModelState.IsValid)
            {
                productdesc.product.CompanyId = c.CompanyId;
                db.products.Add(productdesc.product);
                db.SaveChanges();
                productdesc.Desc.ProdId = productdesc.product.productId;
                db.Descriptions.Add(productdesc.Desc);
                Result = db.SaveChanges();

                if (Result != 1)
                {
                    return(BadRequest("not valid image"));
                }


                return(Ok(new { id = productdesc.product.productId }));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #2
0
 public ProductdescInfo Save()
 {
     if (this.Product_id != null)
     {
         Productdesc.Update(this);
         return(this);
     }
     return(Productdesc.Insert(this));
 }
Example #3
0
        public APIReturn _Add([FromForm] uint?Product_id, [FromForm] string Content)
        {
            ProductdescInfo item = new ProductdescInfo();

            item.Product_id = Product_id;
            item.Content    = Content;
            item            = Productdesc.Insert(item);
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Example #4
0
        public ActionResult Edit([FromQuery] uint Product_id)
        {
            ProductdescInfo item = Productdesc.GetItem(Product_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Example #5
0
        public APIReturn _Del([FromForm] uint[] ids)
        {
            int affrows = 0;

            foreach (uint id in ids)
            {
                affrows += Productdesc.Delete(id);
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"删除成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Example #6
0
        public APIReturn _Edit([FromQuery] uint Product_id, [FromForm] string Content)
        {
            ProductdescInfo item = Productdesc.GetItem(Product_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Content = Content;
            int affrows = Productdesc.Update(item);

            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Example #7
0
 public ProductdescInfo AddProductdesc(string Content) => Productdesc.Insert(new ProductdescInfo {
     Product_id = this.Id,
     Content    = Content
 });