public static SomeModelContract CastToContract( SomeModelModel model) { TinyMapper.Bind <SomeModelModel, SomeModelContract>(); TinyMapper.Bind <SomeModelContract, SomeModelModel>(); return(TinyMapper.Map <SomeModelContract>(model)); }
public async Task <SomeModelModel> CreateAsync(SomeModelModel model) { var nextId = SomeModels.Count + 1; model.Id = nextId; _logger.LogTrace( $"Creating an SomeModel with Id {nextId} based on the command data sent: " + $"{JsonConvert.SerializeObject(model)}"); SomeModels.Add(model); return(model); }
public async Task <SomeModelModel> UpdateAsync( SomeModelModel model) { _logger.LogTrace( $"Updating a SomeModel with Id {model.Id} based on the command data sent: " + $"{JsonConvert.SerializeObject(model)}"); var storedModel = SomeModels.Find(g => g.Id.Equals(model.Id)); if (storedModel == null) { _logger.LogWarning($"No such SomeModel model with Id {model.Id} found. Doing nothing."); return(model); } SomeModels.Remove(storedModel); SomeModels.Add(model); return(model); }