示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        public async Task <DefaultDataResponse> CreateAsync(PartnerPostRequest request)
        {
            var validator        = new PartnerPostRequestValidator();
            var validationResult = validator.Validate(request);

            var existPartner = await partnerRepository.GetByDocument(request.Document);

            if (existPartner != null)
            {
                return(ErrorResponse <MiniErpErrors>(MiniErpErrors.Partner_Post_400_Document_Cannot_Be_Duplicate.ToString()));
            }

            if (!validationResult.IsValid)
            {
                return(ErrorResponse <MiniErpErrors>(validationResult.Errors.ToErrorCodeList()));
            }

            var partner = new PartnerEntity(request);
            var result  = await partnerRepository.CreateAsync(partner);

            return(SuccessResponse(result));
        }