public async Task <IHttpActionResult> SetSaleProduct(ProductSaleInput productSaleInput) { Product_Sale product_Sale = new Product_Sale { Id = IdentityManager.NewId(), Behoof = productSaleInput.Behoof, Des = productSaleInput.Des, FishProductId = productSaleInput.FishProductId, ProductNumber = productSaleInput.ProductNumber, QuasiPurchaseNumber = productSaleInput.ProductNumber, Sale_Time = DateTime.Now, Userid = productSaleInput.Userid, Sale_Price = productSaleInput.Sale_Price, SupplierId = productSaleInput.SupplierId, Is_Or = 1 }; db.Product_Sales.Add(product_Sale); if (await db.SaveChangesAsync() > 0) { return(Json(new { code = 200, msg = "添加销售申请成功" })); } return(Json(new { code = 201, msg = "失败" })); }
public async Task <IHttpActionResult> EdditSaleMonad(ProductSaleInput productSaleInput) { Product_Sale type_res = new Product_Sale { Id = productSaleInput.Id }; // var type_res = await Task.Run(() => db.Product_Sales.SingleOrDefaultAsync(p => p.Id == productSaleInput.Id)); type_res.Behoof = productSaleInput.Behoof; type_res.Des = productSaleInput.Des; type_res.ProductNumber = productSaleInput.ProductNumber; type_res.QuasiPurchaseNumber = productSaleInput.QuasiPurchaseNumber; type_res.Sale_Price = productSaleInput.Sale_Price; type_res.SupplierId = productSaleInput.SupplierId; type_res.Userid = productSaleInput.Userid; db.Configuration.ValidateOnSaveEnabled = false; db.Entry(type_res).State = System.Data.Entity.EntityState.Unchanged; //Type type = typeof(ProductSaleInput); //Assembly assembly = Assembly.GetExecutingAssembly(); //object o = assembly.CreateInstance(type.FullName); //PropertyInfo[] propertyInfos = o.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); //string str = string.Empty; //str += string.Format("类名称:{0}", type.Name); /* if (item.Name != "Id" && item.Name != "z_FnishedProduct" && item.Name != "Supplier" && item.Name != "userDetails")*/ /*item.GetValue(type_res) != null && !string.IsNullOrWhiteSpace(value.ToString()) && name != "Id"&& (long)item.GetValue(type_res) != 0&& (double)item.GetValue(type_res)!=null*/ foreach (var item in type_res.GetType().GetProperties()) { string name = item.Name; // object value = item.GetValue(type_res); object value = item.GetValue(type_res); if (item.GetValue(type_res) != null && value.ToString() != "" && item.Name != "Id" && value.ToString() != "0" && item.Name != "z_FnishedProduct" && item.Name != "Supplier" && item.Name != "userDetails") { Console.WriteLine(item.Name); db.Entry(type_res).Property(item.Name).IsModified = true; } else { if (item.Name != "z_FnishedProduct" && item.Name != "Supplier" && item.Name != "userDetails") { Console.WriteLine(item.Name); db.Entry(type_res).Property(item.Name).IsModified = false; } } } if (await db.SaveChangesAsync() > 0) { db.Configuration.ValidateOnSaveEnabled = true; return(Json(new { code = 200, msg = "修改成功" })); } return(Json(new { code = 301, msg = "修改失败" })); }
public async Task <List <FinshProducRooms> > BackSaleMonad(ProductSaleInput productSaleInput) { var result = await Task.Run(() => db.FnishedProductRooms.AsNoTracking() .Where(p => p.FnishedProductId == productSaleInput.FishProductId && p.del_or == false).Select(p => new FinshProducRooms { FnishedProductId = p.Z_FnishedProduct.Id, EntrepotId = p.entrepot.Id.ToString(), entrepot = p.entrepot }).ToListAsync()); return(result); }