コード例 #1
0
        public HttpResponseMessage Post(CoupleDTO coupleDto)
        {
            var personPartner = new PersonBusiness()
            {
                FirstName = coupleDto.FirstNamePartner,
                LastName  = coupleDto.LastNamePartner,
                CI        = coupleDto.IdPartner,
                Telephone = coupleDto.TelephonePartner,
                Direction = coupleDto.AddressPartner,
                Mail      = coupleDto.MailPartner
            };
            var person = new PersonBusiness()
            {
                FirstName = coupleDto.FirstName,
                LastName  = coupleDto.LastName,
                CI        = coupleDto.Id,
                Telephone = coupleDto.Telephone,
                Direction = coupleDto.Address,
                Mail      = coupleDto.Mail
            };

            var presentList = new PresentListBusiness()
            {
                Quantity = 25
            };

            int IDPersonPartner = _personService.AddPerson(personPartner);
            int IDPerson        = _personService.AddPerson(person);
            int IDPresentList   = _presentListService.Add(presentList);


            var couple = new CoupleBusiness()
            {
                WeddingDate   = coupleDto.WeddingDate,
                DeliveryDate  = coupleDto.DeliveryDate,
                Address       = coupleDto.AddressDelivery,
                HusbandID     = IDPersonPartner,
                WifeID        = IDPerson,
                PresentListID = IDPresentList,
                Latitude      = coupleDto.Latitude,
                Longitude     = coupleDto.Longitude
            };

            int IDCouple = _coupleService.AddCouple(couple);

            var account = new AccountBusiness(person, personPartner, IDCouple);

            _accountService.AddAccount(account);

            AccountDTO accountDTO = new AccountDTO()
            {
                Account          = account.Name,
                Password         = account.Password,
                FirstName        = person.FirstName,
                FirstNamePartner = personPartner.FirstName
            };

            return(Request.CreateResponse(HttpStatusCode.OK, accountDTO));
        }
コード例 #2
0
        public async Task <IActionResult> PostAccountAsync([FromBody] Account account)
        {
            await _accountService.AddAccount(account);

            var newAccount = await _accountService.GetAccount(account.Email);

            return(StatusCode(201, newAccount));
        }
コード例 #3
0
 public ActionResult Create(AccountsCurrent a)
 {
     if (ModelState.IsValid)
     {
         acse.AddAccount(a);
         acse.Commit();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #4
0
        public void Can_Create_Delete_Account()
        {
            var servicePackages    = _lookupService.GetServicePackages();
            var contactTypes       = _lookupService.GetContactTypes().ToList();
            var contactMethods     = _lookupService.GetContactMethods().ToList();
            var paymentMethods     = _lookupService.GetPaymentMethods().ToList();
            var nvralertTypes      = _lookupService.GetNvrAlertTypes().ToList();
            var eventGroups        = _lookupService.GetEventGroups().ToList();
            var analyticAlgorithms = _lookupService.GetAnalyticAlgorithmTypes().ToList();


            //step 1 - create account
            var accountDto = new AccountDto
            {
                AccountNumber    = "123456789",
                Name             = "Test_Account",
                ServicePackageId = servicePackages.ToList().SingleOrDefault(sp => sp.Name == "Silver").ServicePackageId,
                WebSiteURL       = "http://2020Imaging.com",
                Email            = "*****@*****.**",
                Description      = "Test_Account_Description",
                TimeZoneId       = _lookupService.GetTimeZones().First().TimeZoneId,
                AccountTypeId    = _lookupService.GetAccountTypes().Single(at => at.AccoutTypeId == 2).AccoutTypeId,
                AccountBilling   = null,
            };

            var accountId = _accountService.AddAccount(accountDto);

            Assert.IsTrue(accountId > 0);

            var getAccount = _accountService.GetAccount(accountId);

            Assert.IsNotNull(getAccount);

            // step 2 - create person
            var personDto = new PersonDto
            {
                Title     = "Msr.",
                FirstName = "Victor",
                LastName  = "Lungu",
                JobTitle  = "WPF Developer",
                Password  = "******",
                PrimaryAccountAdministratorPassword = "******",
            };

            var preferedContact1 = new PersonContactTypeDto {
                ContactTypeId = contactTypes[0].ContactTypeId
            };
            var preferedContact2 = new PersonContactTypeDto {
                ContactTypeId = contactTypes[1].ContactTypeId
            };

            personDto.PreferedContactTypes = new List <PersonContactTypeDto> {
                preferedContact1, preferedContact2
            };
            var savedPerson = _accountService.SaveAccountPerson(personDto, getAccount.AccountId);

            Assert.IsNotNull(savedPerson);

            // step 3 - create contact
            var contactDto = new ContactDto
            {
                TelephoneNumber = "37379604494",
                EmailAddress    = "*****@*****.**",
                MobileNumber    = "37379604494",
                LyncName        = "Lync Name",
                FaxNumber       = "37379604494",
            };

            var preferedContatMethod1 = new PreferedContatMethodDto
            {
                ContactMethodId = contactMethods[0].ContactMethodId
            };

            var preferedContatMethod2 = new PreferedContatMethodDto
            {
                ContactMethodId = contactMethods[1].ContactMethodId
            };

            contactDto.PreferedContatMethods.Add(preferedContatMethod1);
            contactDto.PreferedContatMethods.Add(preferedContatMethod2);

            var savedContact = _accountService.SaveAccountContact(contactDto, savedPerson.PersonId);

            Assert.IsNotNull(savedContact);

            //step 4 - create accounnt address
            var addressDto = new AddressDto
            {
                AddressNumber   = 3343,
                AddressTypeCode = 22,
                City            = "Chisinau",
                Country         = "Moldova, Republic of",
                County          = "municipiiul Chisinau",
                Fax             = "37379604494",
                Latitude        = 100.22233,
                Line1           = "str. Iazului 6",
                Line2           = "ap. 53",
                Longitude       = 444332,
                Name            = "Main Address",
                PostOfficeBox   = "443332",
                PostalCode      = "PC5543"
            };

            var accountAddress = _accountService.SaveAccountAddress(addressDto, accountId);

            Assert.IsNotNull(accountAddress);

            //step 5 Billing address
            var billingAddress = new AddressDto
            {
                AddressNumber   = 3343,
                AddressTypeCode = 22,
                City            = "Chisinau",
                Country         = "Moldova, Republic of",
                County          = "municipiiul Chisinau",
                Fax             = "37379604494",
                Latitude        = 100.22233,
                Line1           = "str. Iazului 6",
                Line2           = "ap. 53",
                Longitude       = 444332,
                Name            = "Main Address",
                PostOfficeBox   = "443332",
                PostalCode      = "PC5543"
            };

            var accountBilling = new AccountBillingDto
            {
                PaymentMethodId = paymentMethods.First().PaymentMethodId,
                Address         = billingAddress
            };

            var accountBillig = _accountService.SaveAccountBilling(accountBilling, accountId);

            Assert.IsNotNull(accountBillig);

            var accountNvrAlertTypeDto1 = new AccountNvrAlertTypeDto
            {
                NvrAlertTypeId = nvralertTypes.First().NvrAlertTypeId
            };
            var accountNvrAlertTypeDto2 = new AccountNvrAlertTypeDto
            {
                NvrAlertTypeId = nvralertTypes.Last().NvrAlertTypeId
            };

            _accountService.SaveAccountNvrAlertType(
                new List <AccountNvrAlertTypeDto>()
            {
                accountNvrAlertTypeDto1, accountNvrAlertTypeDto2
            }, accountId);

            var accountAlarmPanel1 = new AccountAlarmPanelDto()
            {
                EventGroupId = eventGroups.First().EventGroupId
            };
            var accountAlarmPanel2 = new AccountAlarmPanelDto()
            {
                EventGroupId = eventGroups.Last().EventGroupId
            };

            _accountService.SaveAccountAlarmPanel(
                new List <AccountAlarmPanelDto>()
            {
                accountAlarmPanel1, accountAlarmPanel2
            }, accountId);

            var analyticAlgorithm1 = new AccountAnalyticsAlgorithmTypeDto()
            {
                AnalyticsAlgorithTypeId = analyticAlgorithms.First().AnalyticAlgorithmId
            };
            var analyticAlgorithm2 = new AccountAnalyticsAlgorithmTypeDto()
            {
                AnalyticsAlgorithTypeId = analyticAlgorithms.Last().AnalyticAlgorithmId
            };

            _accountService.SaveAccountAnalyticsAlgorithms(
                new List <AccountAnalyticsAlgorithmTypeDto>()
            {
                analyticAlgorithm1, analyticAlgorithm2
            }, accountId);

            var deleteContact = _accountService.DeleteContact(savedContact.ContactId);

            Assert.IsTrue(deleteContact);

            _accountService.DeletePerson(savedPerson.PersonId);
            var accountDeleted = _accountService.DeleteAccount(getAccount.AccountId);

            Assert.IsTrue(accountDeleted);
        }
コード例 #5
0
 public bool AddAccount([FromBody] VkAccountAddParametrs tokenParams)
 {
     _accountsService.AddAccount(tokenParams.ToDictionary(), AccountType.Vk);
     return(true);
 }