public static TModel FromUserSettings <TModel>(Data.Model.UserSettings userSettings) where TModel : UserSettingsApiModel, new() { var model = new TModel(); model.Id = userSettings.Id; return(model); }
public async Task <AddOrUpdateUserSettingsResponse> Handle(AddOrUpdateUserSettingsRequest request) { var entity = await _context.UserSettings .SingleOrDefaultAsync(x => x.Id == request.UserSettings.Id && x.IsDeleted == false); if (entity == null) { _context.UserSettings.Add(entity = new Data.Model.UserSettings()); } entity.Name = request.UserSettings.Name; await _context.SaveChangesAsync(); return(new AddOrUpdateUserSettingsResponse() { }); }
public static UserSettingsApiModel FromUserSettings(Data.Model.UserSettings userSettings) => FromUserSettings <UserSettingsApiModel>(userSettings);