예제 #1
0
 public void PostValidation(LookupCreateDTO lookupDTO)
 {
     if (string.IsNullOrEmpty(lookupDTO.Name))
     {
         throw new ServiceException(ExceptionMessages.LOOKUP_NAME_CANNOT_BE_BLANK);
     }
     else if (string.IsNullOrEmpty(lookupDTO.Type))
     {
         throw new ServiceException(ExceptionMessages.TYPE_CANNOT_BE_BLANK);
     }
 }
예제 #2
0
        public void Add(LookupCreateDTO lookupDTO)
        {
            Lookup lookup = new Lookup {
                Name        = lookupDTO.Name,
                Type        = lookupDTO.Type,
                OrderId     = lookupDTO.OrderId,
                CreatedDate = DateTime.Now,
                UpdatedDate = null
            };

            _context.Lookups.Add(lookup);
            _context.SaveChanges();
        }
예제 #3
0
 public IActionResult Post(LookupCreateDTO lookupCreateDTO)
 {
     try
     {
         _lookupService.PostValidation(lookupCreateDTO);
         _lookupService.Add(lookupCreateDTO);
         return(Ok());
     }
     catch (AuthenticationException)
     {
         return(Forbid());
     }
     catch (ServiceException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.StackTrace));
     }
 }