protected virtual bool DoCreate <TEntity, TModel>(ICommandCreateBase <TModel> command, IRpstBase <TEntity> repository) where TEntity : DtoBase { TEntity entity; try { entity = Mapper.Map <TEntity>(command.Model); repository.Add(Context, entity); return(true); } catch { SericeResult.ErrorMessages.Add(Constants.CommonMessages.AUTO_MAPPING_DOMAIN_TO_DATA_FAILED); SericeResult.Success = false; return(false); } }
// // Summary: // Get an entity from database. // Return: // The entity will be deleted in database. protected virtual TEntity GetDeleteEntity(IRpstBase <TEntity> repository, TCommand command) { return(repository.GetById(command.Model)); }
// // Summary: // Get an entity from database. // Return: // The entity will be modified and updated to database. protected virtual async Task <TEntity> GetOldEntityAsync(IRpstBase <TEntity> repository, TCommand command) { return(repository.GetById(command.Model.Id)); }