Пример #1
0
        public ResponseDto Save(PersonAddressDto saveDto)
        {
            ResponseDto responseDto = new ResponseDto();

            PersonAddressBo personAddressBo = new PersonAddressBo()
            {
                Id                 = saveDto.Id,
                AddressTypeId      = saveDto.AddressTypeId,
                PersonId           = saveDto.PersonId,
                InvolvedPersonName = saveDto.InvolvedPersonName,
                StatId             = saveDto.StatId,
                Name               = saveDto.Name,

                CountryId  = saveDto.CountryId,
                StateId    = saveDto.StateId,
                CityId     = saveDto.CityId,
                DistrictId = saveDto.DistrictId,
                LocalityId = saveDto.LocalityId,

                ZipCode = saveDto.ZipCode,
                Notes   = saveDto.Notes,
                Phone   = saveDto.Phone,

                Session = Session
            };

            ResponseBo responseBo = personAddressBusiness.Save(personAddressBo);

            responseDto = responseBo.ToResponseDto();

            return(responseDto);
        }
Пример #2
0
        public async Task <PersonAddressDto> PutPersonAddress(int id, PersonAddressDto model)
        {
            var url    = CRMApiUri + "/PersonAddress/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
Пример #3
0
        public async Task <PersonAddressDto> PostPersonAddress(PersonAddressDto model)
        {
            var url    = CRMApiUri + "/PersonAddress";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
Пример #4
0
        public IActionResult Save(PersonAddressDto model)
        {
            bool success;

            model = model.Id == 0 ? _personAddressApiClient.PostPersonAddress(model).Result
                : _personAddressApiClient.PutPersonAddress(model.Id, model).Result;
            success = string.IsNullOrWhiteSpace(model.ErrorMessage);
            return(Json(new { success, message = success ? model.SuccessMessage : model.ErrorMessage }));
        }
Пример #5
0
        public async Task <IActionResult> Put(int id, [FromBody] PersonAddressDto personAddressDto)
        {
            if (id == 0 || personAddressDto.Id == 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _personAddressService.SaveAndReturnEntityAsync(personAddressDto)));
        }
Пример #6
0
        public async Task <IActionResult> Post([FromBody] PersonAddressDto personAddressDto)
        {
            if (personAddressDto.Id != 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _personAddressService.SaveAndReturnEntityAsync(personAddressDto)));
        }
Пример #7
0
 public async Task <CommandHandlerAnswerDto <PersonAddressDto> > Save(PersonAddressDto address)
 {
     using (busyIndicatorService.Show())
     {
         if (address.Id != Guid.Empty)
         {
             return(await personAddressService.Put(address));
         }
         return(await personAddressService.Post(address));
     }
 }
Пример #8
0
        public async Task <BaseEntity> SaveAndReturnEntityAsync(PersonAddressDto entityDto)
        {
            var personAddress = _mapper.Map <PersonAddress>(entityDto);
            var address       = _mapper.Map <Address>(personAddress.Address);

            address = await _repository.SaveAndReturnEntityAsync(address);

            if (personAddress.AddressId == 0)
            {
                personAddress.Address   = null;
                personAddress.AddressId = address.Id;
                personAddress           = await _repository.SaveAndReturnEntityAsync(personAddress);
            }
            personAddress.SuccessMessage = "The data is saved successfully";
            return(personAddress);
        }
Пример #9
0
 public async Task <PersonAddressDto> PutPersonAddress(int id, PersonAddressDto model)
 {
     return(await _personAddressApiClient.PutPersonAddress(id, model));
 }
Пример #10
0
 public async Task <PersonAddressDto> PostPersonAddress(PersonAddressDto model)
 {
     return(await _personAddressApiClient.PostPersonAddress(model));
 }
        public async Task <ICommandHandlerAggregateAnswer> Update(Guid personId, PersonAddressDto dto)
        {
            var command = Mapper.Map(dto).ToANew <AddressUpdateCommand>();

            return(await dispatcher.Send <AddressUpdateCommand, Person>(command));
        }
        public async Task <ICommandHandlerAggregateAnswer> Create(Guid personId, PersonAddressDto dto)
        {
            var command = Mapper.Map(dto).OnTo(new AddressCreateCommand());

            return(await dispatcher.Send <AddressCreateCommand, Person>(command));
        }
        public async Task <IActionResult> PostAddress(Guid personId, [FromBody] PersonAddressDto dto)
        {
            var result = await addressApplication.Create(personId, dto);

            return(result.ValidationResult.IsValid ? Ok(result) : (IActionResult)BadRequest(result));
        }
        public async Task <IActionResult> PutAddress(Guid personId, [FromBody] PersonAddressDto dto)
        {
            var result = await addressApplication.Update(personId, dto);

            return(result.IsNotNull() ? (IActionResult)Ok(result) : NotFound(new { personId, dto }));
        }
 public async Task <CommandHandlerAnswerDto <PersonAddressDto> > Put(PersonAddressDto address)
 {
     return(await requestService.PutAsync <PersonAddressDto, CommandHandlerAnswerDto <PersonAddressDto> >(
                $"{apiSettings.MainUrl}/{Endpoint}/{address.PersonId}/{Controller}", address));
 }
Пример #16
0
        public async Task <int> SaveAsync(PersonAddressDto personAddress)
        {
            var result = await SaveAndReturnEntityAsync(personAddress);

            return(result.Id);
        }