Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 //
 // 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));
 }
Ejemplo n.º 3
0
 //
 // 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));
 }