public Result <int> Save(CodeMapperItem entity) { switch (entity.EntityState) { case ItemState.Added: return(_commandRepository.Add(entity.MapTo <CodeMappers>()).MapResultTo <int, object>()); case ItemState.Modified: if (!entity.IsDefault) { return(_commandRepository.InlineUpdate(entity, entity.Id)); } return(ResetDefault().Bind <int>(x => _commandRepository.InlineUpdate(entity, entity.Id))); case ItemState.Delete: return(_commandRepository.Delete(entity.Id)); case ItemState.Unchanged: return(Result <int> .Fail <int>("Unchanged Object. Nothing to save")); default: return(Result <int> .Fail <int>("Entity state unknown")); } }
public Result <int> Save(CodeMapperItem entity) => _command.Save(entity);
public Result <int> Put(int id, [FromBody] CodeMapperItem entity) { entity.EntityState = ItemState.Modified; return(_services.Save(entity)); }
public Result <int> Post([FromBody] CodeMapperItem entity) { entity.EntityState = ItemState.Added; return(_services.Save(entity)); }