Beispiel #1
0
 /// <summary>
 /// Construtor da Entidade PartnerEntity que receberá o contrato.
 /// </summary>
 public PartnerEntity(PartnerPutRequest obj)
 {
     this.PartnerId   = obj.PartnerId;
     this.Name        = obj.Name;
     this.Document    = obj.Document;
     this.Situation   = obj.Situation;
     this.Status      = obj.Status;
     this.PartnerCode = obj.PartnerCode;
 }
Beispiel #2
0
        public async Task <DefaultDataResponse> UpdateAsync(PartnerPutRequest request)
        {
            var validator        = new PartnerPutRequestValidator();
            var validationResult = validator.Validate(request);

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

            if (existPartner != null && existPartner.PartnerId != request.PartnerId)
            {
                return(ErrorResponse <MiniErpErrors>(MiniErpErrors.Partner_Put_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));
        }
Beispiel #3
0
        public async Task <IActionResult> Put([FromBody] PartnerPutRequest request)
        {
            var result = await partnerService.UpdateAsync(request);

            return(HttpHelper.Convert(result));
        }