public static User AsEntity(this UserPut model) { var entity = new User(); model.ApplyTo(entity); return(entity); }
public async Task <IActionResult> PutUser(UserPut model) { var entity = await Services.Context.Users.FirstOrDefaultAsync(x => x.UserId.Equals(model.UserId)); if (entity == null) { return(await CreateUser(model)); } model.ApplyTo(entity); await Services.Context.SaveChangesAsync(); return(Ok(entity.AsModel())); }