static public async Task <string> Save(EBaseEntity eBaseEntity) { eBaseEntity.modificationDateUTC = DateTime.UtcNow; using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eBaseEntity.id)) { eBaseEntity.id = Guid.NewGuid().ToString(); eBaseEntity.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } else { var e = context.BaseUsers.Update(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList); return(eBaseEntity.id); }
static public bool SaveProfile(EBaseEntity eBaseEntity) { using var context = new SMySQLContext(); EBaseEntity oldEntity = context.BaseUsers.SingleOrDefault(x => x.id == eBaseEntity.id); oldEntity.email = eBaseEntity.email; oldEntity.password = eBaseEntity.password; context.BaseUsers.Update(oldEntity); return(SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList)); }