public async Task <PersonProfileResponse> UpdateAsync(int id, PersonProfile customer)
        {
            var existingCustomer = await _customerRepository.FindByIdAsync(id);

            if (existingCustomer == null)
            {
                return(new PersonProfileResponse("customer not found"));
            }

            existingCustomer.Name     = customer.Name;
            existingCustomer.LastName = customer.LastName;
            existingCustomer.Phone    = customer.Phone;
            existingCustomer.Age      = customer.Age;
            existingCustomer.Email    = customer.Email;
            existingCustomer.Document = customer.Document;
            existingCustomer.Photo    = customer.Photo;


            try
            {
                _customerRepository.Update(existingCustomer);
                await _unitOfWork.CompleteAsync();

                return(new PersonProfileResponse(existingCustomer));
            }
            catch (Exception ex)
            {
                return(new PersonProfileResponse($"An error ocurred while updating the customer: {ex.Message}"));
            }
        }
Beispiel #2
0
        public async Task <RequestResponse> SaveByCustomerIdAsync(int customerId, int providerId, int productTypeId, int productId, int petId, PersonRequest request)
        {
            PersonProfile customer = await _customerRepository.FindByIdAsync(customerId);

            Product product = await _productepository.FindByIdAsync(productId);

            /*  Pet pet = await _petRepository.FindByIdAsync(petId);
             * Provider provider = await _providerRepository.FindByIdAsync(providerId);*/
            try
            {
                /*    if (  pet.Id == petId )
                 *  {*/
                request.PetId           = petId;
                request.PersonProfileId = customerId;
                request.PersonProfile   = customer;
                request.ProviderId      = providerId;
                request.ProductTypeId   = productTypeId;
                request.Product         = product;
                request.ProductId       = productId;
                request.Status          = 1;

                await _requestRepository.SaveByCustomerIdAsync(request);

                await _unitOfWork.CompleteAsync();

                return(new RequestResponse(request));

                /*      }
                 *    return new RequestResponse("not found request");
                 */
            }
            catch (Exception ex)
            {
                return(new RequestResponse($"An error ocurred while saving the request: {ex.Message}"));
            }
        }
Beispiel #3
0
        public async Task <ReviewResponse> SaveByCustomerIdAsync(int personId, int providerId, Review Review)
        {
            PersonProfile customer = await _personProfileRepository.FindByIdAsync(personId);

            Provider provider = await _providerRepository.FindByIdAsync(providerId);

            try
            {
                Review.PersonProfile   = customer;
                Review.PersonProfileId = personId;
                Review.Provider        = provider;
                Review.ProviderId      = providerId;

                await _reviewRepository.SaveByCustomerIdAsync(Review);

                await _unitOfWork.CompleteAsync();

                return(new ReviewResponse(Review));
            }
            catch (Exception ex)
            {
                return(new ReviewResponse($"An error ocurred while saving the review: {ex.Message}"));
            }
        }