public ReturnObject UpdateAsset(ModelViews.ViewAsset entity) { ReturnObject obj = new ReturnObject(); obj.status = -1; using (var transaction = tWG_ACHECKContext.Database.BeginTransaction()) { try { DaoAsset daoAsset = new DaoAsset(tWG_ACHECKContext); var result = daoAsset.UpdateAsset(entity.asset, entity.assign); if (result > 0) { obj.status = 1; } obj.value = result; transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); obj.status = -1; obj.message = ex.StackTrace; } } return(obj); }
public async Task <ReturnObject> Update() { IFormFileCollection formFiles = Request.Form.Files; ModelViews.ViewAsset entity = JsonConvert.DeserializeObject <ModelViews.ViewAsset>(Request.Form["entity"].ToString()); ReturnObject obj = new ReturnObject(); obj.status = -1; using (var transaction = tWG_ACHECKContext.Database.BeginTransaction()) { try { DaoAsset daoAsset = new DaoAsset(tWG_ACHECKContext); int result = await daoAsset.Update(entity, formFiles); if (result > 0) { obj.status = 1; } obj.value = result; transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); obj.status = -1; obj.message = ex.StackTrace; } } return(obj); }