コード例 #1
0
        public ApiResult <bool> Update(DeviceModelDto m)
        {
            var dm = _context.DeviceModels.SingleOrDefault(c => c.DeviceModelId == m.DeviceModelId);

            if (dm != null)
            {
                dm.ModelName = m.ModelName;
                dm.ModelDesc = m.ModelDesc;
                _context.DeviceModels.Update(dm);
                _context.SaveChanges();
                return(new ApiResult <bool>(ApiCode.CantFindObject, "Ok", true));
            }
            return(new ApiResult <bool>(ApiCode.CantFindObject, "CantFindObject", false));
        }
コード例 #2
0
 public ApiResult <bool> Save(DeviceModelDto m)
 {
     try
     {
         DeviceModel dm = new DeviceModel();
         dm.CreateDateTime = DateTime.Now;
         dm.ModelStatus    = 1;
         dm.ModelName      = m.ModelName;
         dm.ModelDesc      = m.ModelDesc;
         _context.DeviceModels.Update(dm);
         _context.SaveChanges();
         return(new ApiResult <bool>(ApiCode.CantFindObject, "Ok", true));
     }
     catch (Exception ex)
     {
         return(new ApiResult <bool>(ApiCode.Exception, ex.Message, false));
     }
 }