public async Task CreateAsync(CustomerAuditor customerAuditorToAdd) { Stopwatch timespan = Stopwatch.StartNew(); try { db.CustomerAuditors.Add(customerAuditorToAdd); await db.SaveChangesAsync(); //Seteamos el Rol SetRole(customerAuditorToAdd.UserId); timespan.Stop(); log.TraceApi("SQL Database", "CustomerAuditorRespository.CreateAsync", timespan.Elapsed, "customerAuditorToAdd={0}", customerAuditorToAdd); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { //Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); log.Error(e, "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { //Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); log.Error(e, "- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } catch (Exception e) { log.Error(e, "Error in CustomerAuditorRespository.CreateAsync(customerAuditorToAdd={0})", customerAuditorToAdd); throw; } }
public void Update(CustomerAuditor customerAuditor) { //throw new NotImplementedException(); var idManager = new IdentityManager(); var result = idManager.UpdateUser(customerAuditor.User); }
public async Task <CustomerAuditor> FindByIdAsync(int customerAuditorID) { CustomerAuditor customerAuditor = null; Stopwatch timespan = Stopwatch.StartNew(); try { customerAuditor = await db.CustomerAuditors.FindAsync(customerAuditorID); timespan.Stop(); log.TraceApi("SQL Database", "CustomerAuditorRespository.FindByIdAsync", timespan.Elapsed, "customerAuditorID={0}", customerAuditorID); } catch (Exception e) { log.Error(e, "Error in CustomerAuditorRespository.FindByIdAsync(customerAuditorID={0})", customerAuditorID); throw; } return(customerAuditor); }
public async Task Delete(int customerAuditorID) { CustomerAuditor customerAuditor = null; Stopwatch timespan = Stopwatch.StartNew(); try { customerAuditor = await db.CustomerAuditors.FindAsync(customerAuditorID); var userId = customerAuditor.UserId; db.CustomerAuditors.Remove(customerAuditor); db.SaveChanges(); DeleteUser(userId); timespan.Stop(); log.TraceApi("SQL Database", "CustomerAuditorRespository.Delete", timespan.Elapsed, "customerAuditorID={0}", customerAuditorID); } catch (Exception e) { log.Error(e, "Error in CustomerAuditorRespository.Delete(customerAuditorID={0})", customerAuditorID); throw; } }