Ejemplo n.º 1
0
        public async Task <IHttpActionResult> AddChemistryRoom(ChemistryIntDto chemistryIntDto)
        {
            try
            {
                ChemistryRoom chemistryRoom = new ChemistryRoom
                {
                    Id                = IdentityManager.NewId(),
                    ChemistryId       = chemistryIntDto.ChemistryId,
                    User_id           = chemistryIntDto.User_id,
                    EntrepotId        = chemistryIntDto.EntrepotId,
                    RawNumber         = chemistryIntDto.RawNumber,
                    RawOutNumber      = chemistryIntDto.RawOutNumber,
                    Warning_RawNumber = chemistryIntDto.Warning_RawNumber,
                    RoomDes           = chemistryIntDto.RoomDes,
                };
                db.ChemistryRooms.Add(chemistryRoom);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "添加成功" }));
                }

                return(Json(new { code = 201, msg = "添加失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 public async Task <IHttpActionResult> RemoveChemistryRoom(ChemistryIntDto chemistryIntDto)
 {
     try
     {
         if (chemistryIntDto.del_Id != null)
         {
             foreach (var item in chemistryIntDto.del_Id)
             {
                 var result = new ChemistryRoom {
                     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;
     }
 }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> EditChemistryRoom(ChemistryIntDto chemistryIntDto)
        {
            try
            {
                var ChemistryRoom = new ChemistryRoom {
                    Id = chemistryIntDto.Id
                };
                db.Entry(ChemistryRoom).State = System.Data.Entity.EntityState.Unchanged;
                if (chemistryIntDto.ChemistryId != null)
                {
                    ChemistryRoom.ChemistryId = chemistryIntDto.ChemistryId;
                }
                if (chemistryIntDto.User_id != null)
                {
                    ChemistryRoom.User_id = chemistryIntDto.User_id;
                }
                if (chemistryIntDto.EntrepotId != null)
                {
                    chemistryIntDto.EntrepotId = chemistryIntDto.EntrepotId;
                }
                if (chemistryIntDto.RawNumber != null)
                {
                    ChemistryRoom.RawNumber = chemistryIntDto.RawNumber;
                }
                if (chemistryIntDto.RawOutNumber != null)
                {
                    ChemistryRoom.RawOutNumber = chemistryIntDto.RawOutNumber;
                }
                if (chemistryIntDto.Warning_RawNumber != null)
                {
                    ChemistryRoom.Warning_RawNumber = chemistryIntDto.Warning_RawNumber;
                }

                if (!string.IsNullOrWhiteSpace(chemistryIntDto.RoomDes))
                {
                    ChemistryRoom.RoomDes = chemistryIntDto.RoomDes;
                }

                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "修改成功" }));
                }

                return(Json(new { code = 201, msg = "修改失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }