public async Task <IHttpActionResult> RemoveMaterialCode(Z_MaterialCodeDto z_MaterialCodeDto)
 {
     try
     {
         if (z_MaterialCodeDto.del_Id != null)
         {
             foreach (var item in z_MaterialCodeDto.del_Id)
             {
                 var result = new Z_MaterialCode {
                     Id = item
                 };
                 //  var result = Task.Run(() => (db.Z_Office.AsNoTracking().FirstOrDefault(m => m.Id == item)));
                 db.Entry(result).State = System.Data.Entity.EntityState.Deleted;
             }
             if (await db.SaveChangesAsync() > 0)
             {
                 return(Json(new { code = 200, msg = "删除成功" }));
             }
             else
             {
                 return(Json(new { code = 400, msg = "删除失败" }));
             }
         }
         else
         {
             return(Json(new { code = 201, msg = "请勿传递空数据" }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public async Task <IHttpActionResult> AddMaterialCode(Z_MaterialCodeDto z_MaterialCodeDto)
 {
     try
     {
         if (ModelState.IsValid)
         {
             string         Moren          = " N / A";
             Z_MaterialCode z_MaterialCode = new Z_MaterialCode
             {
                 Id                = IdentityManager.NewId(),
                 Name              = z_MaterialCodeDto.Name,
                 Encoding          = z_MaterialCodeDto.Encoding != null ? z_MaterialCodeDto.Encoding : Moren,
                 EntryPersonId     = z_MaterialCodeDto.EntryPersonId,
                 Desc              = z_MaterialCodeDto.Desc,
                 CompanyId         = z_MaterialCodeDto.Companyid,
                 Z_RowTypeid       = z_MaterialCodeDto.Z_RowTypeid,
                 EnglishName       = z_MaterialCodeDto.EnglishName != null ? z_MaterialCodeDto.EnglishName : Moren,
                 Abbreviation      = z_MaterialCodeDto.Abbreviation != null ? z_MaterialCodeDto.Abbreviation : Moren,
                 BeCommonlyCalled1 = z_MaterialCodeDto.BeCommonlyCalled1 != null ? z_MaterialCodeDto.BeCommonlyCalled1 : Moren,
                 BeCommonlyCalled2 = z_MaterialCodeDto.BeCommonlyCalled2 != null ? z_MaterialCodeDto.BeCommonlyCalled2 : Moren,
                 CASNumber         = z_MaterialCodeDto.CASNumber != null ? z_MaterialCodeDto.CASNumber : Moren,
                 MolecularWeight   = z_MaterialCodeDto.MolecularWeight != null ? z_MaterialCodeDto.MolecularWeight : Moren,
                 MolecularFormula  = z_MaterialCodeDto.MolecularFormula,
                 StructuralFormula = z_MaterialCodeDto.StructuralFormula,
                 Density           = z_MaterialCodeDto.Density,
                 Number            = z_MaterialCodeDto.Number,
                 Statement         = z_MaterialCodeDto.Statement != null ? z_MaterialCodeDto.Statement : Moren,
                 Caution           = z_MaterialCodeDto.Caution != null ? z_MaterialCodeDto.Caution : Moren,
                 AppearanceState   = z_MaterialCodeDto.AppearanceState != null ? z_MaterialCodeDto.AppearanceState : Moren,
                 WarehousingTypeId = z_MaterialCodeDto.WarehousingTypeId,
             };
             db.Z_MaterialCode.Add(z_MaterialCode);
             if (await db.SaveChangesAsync() > 0)
             {
                 return(Json(new { code = 200, msg = "添加成功" }));
             }
             else
             {
                 return(Json(new { code = 400, msg = "添加失败" }));
             }
         }
         else
         {
             return(Json(new { code = 201, msg = "请勿添加空数据" }));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }