public static TimeLogType DtoToModel(TimeLogTypeDto dto)
 {
     if (dto == null)
     {
         return(null);
     }
     return(new TimeLogType {
         Type = dto.TimeLogType, Budget = dto.Budget
     });
 }
 public OperationResult Create(TimeLogTypeDto dto)
 {
     try
     {
         var model = TimeLogTypeMapping.DtoToModel(dto);
         if (model == null || string.IsNullOrEmpty(model.Type) || model.Budget == 0)
         {
             return(new OperationResult
             {
                 BrokenRulesCollection = new BrokenRulesCollection(
                     new List <BrokenRule> {
                     new BrokenRule {
                         Description = model.Budget == 0 ? "Budget can not be '0'.": "Invalid Time Log Type to create.",
                         Severity = RuleSeverity.Error
                     }
                 })
             });
         }
         model.Type = model.Type.ToUpper();
         _timeLogTypeRepository.Create(model);
         //success, no broken rules by error
         return(new OperationResult());
     }
     catch (Exception ex)
     {
         return(new OperationResult {
             BrokenRulesCollection = new BrokenRulesCollection(
                 new List <BrokenRule> {
                 new BrokenRule {
                     Description = ex.Message,
                     Severity = RuleSeverity.Error
                 }
             })
         });
     }
 }
 public OperationResult Create([FromBody] TimeLogTypeDto dto)
 {
     return(_timeLogTypeService.Create(dto));
 }