public async Task <ReturnObject> UpdateAttribute(EavAttribute entity) { ReturnObject obj = new ReturnObject(); obj.status = -1; using (var transaction = tWG_ACHECKContext.Database.BeginTransaction()) { try { DaoEAVAttribute daoEAVAttribute = new DaoEAVAttribute(tWG_ACHECKContext); int result = await daoEAVAttribute.UpdateEavAttribute(entity); 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 <int> UpdateEavAttribute(EavAttribute eavAttribute) { var entity = context.EavAttribute.Where(p => p.Guid.Equals(eavAttribute.Guid)).FirstOrDefault(); eavAttribute.CopyPropertiesTo <EavAttribute>(entity); context.EavAttribute.Update(entity); return(await context.SaveChangesAsync()); }
public async Task <int> AddEavAttribute(EavAttribute entity) { entity.Guid = this.GenerateEavAttributeID(); context.EavAttribute.Add(entity); return(await context.SaveChangesAsync()); }