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); } }
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(); }
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)); } }