Beispiel #1
0
 public async Task <ActionResult <PartnerInformation> > CreatePartner(PartnerInformation partnerInformation)
 {
     if (partnerInformation is null)
     {
         return(BadRequest(new ArgumentNullException()));
     }
     try
     {
         return(await _repository.AddPartner(partnerInformation));
     }
     catch (Exception)
     {
         return(Conflict());
     }
 }
        public APIAddPartnerResponse AddPartner(PartnerInformation newPartner)
        {
            Invoicing_v2.InvoicingSoapClient client = GetAPIClient();

            var request = new NewPartnerInformation()
            {
                UserName         = newPartner.UserName,
                UserEmail        = newPartner.UserEmail,
                UserPhone        = newPartner.UserPhone,
                CompanyTaxId     = newPartner.CompanyTaxId,
                CompanyLegalName = newPartner.CompanyLegalName,
                CompanyAddress   = newPartner.CompanyAddress,
                CompanyCity      = newPartner.CompanyCity,
                CompanyPostCode  = newPartner.CompanyPostCode,
                CompanyCountry   = newPartner.CompanyCountry
            };

            var serviceResponse = client.AddPartnerAsync(GetAuthenticationCredentials(), request).Result;

            return(AddPartnerAPIResponse(serviceResponse));
        }
        public async Task <ActionResult <PartnerInformation> > AddPartner(PartnerInformation partnerInformation)
        {
            context.PartnerInfo.Add(partnerInformation);
            try
            {
                await context.SaveChangesAsync().ConfigureAwait(false);

                return(await context.PartnerInfo.FindAsync(partnerInformation.Email));
            }
            catch (DbUpdateException)
            {
                if (!PartnerExist(partnerInformation.Email))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #4
0
 public async Task <ActionResult <PartnerInformation> > EditPartnerDetails(string email, PartnerInformation partnerInformation)
 {
     try
     {
         return(await _repository.ChangePartnerDetails(email, partnerInformation));
     }
     catch (DbUpdateConcurrencyException)
     {
         return(NotFound());
     }
     catch
     {
         return(NoContent());
     }
 }
        public async Task <ActionResult <PartnerInformation> > ChangePartnerDetails(string email, PartnerInformation partnerInformation)
        {
            if (email != partnerInformation.Email)
            {
                return(null);
            }

            context.Entry(partnerInformation).State = EntityState.Modified;
            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PartnerExist(email))
                {
                    throw new DbUpdateConcurrencyException();
                }
                else
                {
                    throw;
                }
            }
            return(partnerInformation);
        }