public virtual Money GetShippingPrice(IEnumerator cart, Entity.Address shippingTo)
 {
     return(new Money()
     {
         Value = 20,
         Currency = Money.CurrencyType.RUB
     });
 }
 public override Money GetShippingPrice(IEnumerator cart, Entity.Address shippingTo)
 {
     //TODO
     return(new Money()
     {
         Value = 30,
         Currency = Money.CurrencyType.RUB
     });
 }
        public object Completo(Entity.Address address)
        {
            if (Equals(address, null))
            {
                return(null);
            }

            return(new
            {
                Id = address.Id,
                Rua = address.Rua
            });
        }
        public async Task <IWriterResult <string> > GenerateAddress(string userId, string currency)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                var currencyEntity = await context.Currency.FirstOrDefaultNoLockAsync(x => x.Symbol == currency && x.IsEnabled);

                if (currencyEntity == null)
                {
                    return(WriterResult <string> .ErrorResult("Currency not found."));
                }

                var addressAccount = currencyEntity.InterfaceType == Enums.CurrencyInterfaceType.NoAccount ? string.Empty : userId;
                var newAddress     = await WalletService.GenerateAddress(addressAccount, currencyEntity.WalletHost, currencyEntity.WalletPort, currencyEntity.WalletUser, currencyEntity.WalletPass);

                if (newAddress == null)
                {
                    return(WriterResult <string> .ErrorResult("Failed to generate address for {0}.", currencyEntity.Name));
                }

                var currentAddresses = await context.Address.Where(x => x.UserId == userId && x.CurrencyId == currencyEntity.Id && x.IsActive).ToListNoLockAsync();

                foreach (var currentAddress in currentAddresses)
                {
                    currentAddress.IsActive = false;
                }

                var addressEntity = new Entity.Address
                {
                    AddressHash = newAddress.Address,
                    PrivateKey  = newAddress.PrivateKey,
                    CurrencyId  = currencyEntity.Id,
                    UserId      = userId,
                    IsActive    = true,
                };

                context.Address.Add(addressEntity);
                await context.SaveChangesAsync();

                return(WriterResult <string> .SuccessResult(data : newAddress.Address, message : "Successfully generated address"));
            }
        }
Beispiel #5
0
        public void TestService()
        {
            UnitOfWork uw = new UnitOfWork(new Entity.K_12Entities());

            IContactService cont_serv = new ContactService(uw.Contacts);

            Entity.Contact c = cont_serv.Find(2);

            Entity.Address a = new Entity.Address();

            a.Email = "*****@*****.**";

            c.Address = a;

            cont_serv.Update(c);

            uw.Save();

            Entity.Contact c2 = cont_serv.Find(c.ID);


            Assert.AreEqual(c.Address.Email, c2.Address.Email);
        }
        public async Task <AddressModel> GetAddress(string userId, int currencyId)
        {
            var currency = await CurrencyReader.GetCurrency(currencyId);

            if (currency == null)
            {
                return new AddressModel {
                           ErrorMessage = "Currency not found."
                }
            }
            ;

            if (currency.ListingStatus != Enums.CurrencyListingStatus.Active)
            {
                return new AddressModel {
                           ErrorMessage = $"Unable to generate address for {currency.Symbol}, Reason: {currency.ListingStatus}"
                }
            }
            ;

            if (currency.Status != Enums.CurrencyStatus.OK)
            {
                return new AddressModel {
                           ErrorMessage = $"Unable to generate address for {currency.Symbol}, Reason: {currency.StatusMessage}"
                }
            }
            ;

            var currentUser = new Guid(userId);

            using (var context = ExchangeDataContextFactory.CreateReadOnlyContext())
            {
                var existingAddress = await GetAddressModel(context, currencyId, currentUser);

                if (existingAddress != null)
                {
                    return(existingAddress);
                }
            }

            var newAddress = await DepositService.GenerateAddress(currentUser, currencyId);

            if (newAddress == null || newAddress.Count < 2)
            {
                return new AddressModel {
                           ErrorMessage = "Failed to generate new address"
                }
            }
            ;

            using (var context = ExchangeDataContextFactory.CreateContext())
            {
                var address = new Entity.Address
                {
                    AddressHash = newAddress[0],
                    PrivateKey  = newAddress[1],
                    UserId      = currentUser,
                    CurrencyId  = currencyId
                };

                context.Address.Add(address);
                await context.SaveChangesAsync().ConfigureAwait(false);

                return(await GetAddressModel(context, currencyId, currentUser));
            }
        }
Beispiel #7
0
 public virtual Money GetShippingPrice(IEnumerator cart, Entity.Address shippingTo)
 {
     return(shippingTo.Price);
 }
 public override Money GetShippingPrice(IEnumerator cart, Entity.Address shippingTo)
 {
     //TODO
     return(shippingTo.Price);
 }
		private void submit_Click(object sender, RoutedEventArgs e)
		{
			if (((customId.Text == string.Empty) || (firstName.Text == string.Empty) || (lastName.Text == string.Empty) ||
				(street.Text == string.Empty) || (city.Text == string.Empty) ||
				(zip.Text == string.Empty) || (email.Text == string.Empty) ||
			  (name.Text == string.Empty) || (country.SelectedValue == null) || !this.marked)
				|| (this.c != "FO" && (this.ico.Text == string.Empty || this.icDph.Text == string.Empty
					|| this.dic.Text == string.Empty || this.name.Text == string.Empty)))
			{
				System.Windows.MessageBox.Show("Musia byť vyplnené poviné údaje");
				return;
			}
			if ((customId.Text.Contains(";")) || (titlePrefix.Text.Contains(";")) ||
						(firstName.Text.Contains(";")) || (lastName.Text.Contains(";")) ||
						(titleSuffix.Text.Contains(";")) || (street.Text.Contains(";")) ||
						(city.Text.Contains(";")) || (zip.Text.Contains(";")) || (email.Text.Contains(";")) ||
					  (name.Text.Contains(";")) || (mobile.Text.Contains(";")) || (ico.Text.Contains(";"))
			 || (dic.Text.Contains(";")) || (icDph.Text.Contains(";")))
			{
				System.Windows.MessageBox.Show("Znak ; je vyhradeni, prosím zmente vstup tak aby neobsahoval znak ; ");
				return;
			}
			Entity.Order order = new Entity.Order();
			order.products = new List<Interface.IOrderItem>();
			Entity.Company company = new Entity.Company();
			company.custom_id = customId.Text.ToString();

			Entity.Person person = new Entity.Person();
			person.titlePrefix = titlePrefix.Text.ToString();
			person.firstName = firstName.Text.ToString();
			person.lastName = lastName.Text.ToString();
			person.titleSuffix = titleSuffix.Text.ToString();

			Entity.Address address = new Entity.Address();
			address.street = street.Text.ToString();
			address.city = city.Text.ToString();
			address.zip = zip.Text.ToString();
			address.country = country.Text.ToString() == "Vyberte krajinu" ? "SVK" : country.Text.ToString();

			Entity.Contact contact = new Entity.Contact();
			contact.email = email.Text.ToString();
			contact.mobile = mobile.Text.ToString();

			company.person = person;
			company.address = address;
			company.contact = contact;

			switch (this.c.ToUpper())
			{
				case "PO":
					{ company.corporatePerson = Interface.CorporatePerson.PO; break; }
				default:
					{ company.corporatePerson = Interface.CorporatePerson.FO; break; }
			}
			if (this.c.ToUpper() != "FO")
			{
				company.name = name.Text.ToString();
				company.ico = ico.Text.ToString();
				company.dic = dic.Text.ToString();
				company.icDph = icDph.Text.ToString();
			}
			else
				company.name = company.person.getFullName();

			//company.id = 1;
			//if (Settings.Config.getCompanies().Count > 0)
			//	company.id = Settings.Config.getCompanies().LastOrDefault(x => x.id > 0).id + 1;

			//order.id = 1;
			//if (Settings.Config.getOrders().Count > 0)
			//	order.id = Settings.Config.getOrders().LastOrDefault(x => x.id > 0).id + 1;

			order.company = company;
			//Settings.Config.getCompanies().Add(company);
			//Settings.Config.getOrders().Add(order);
			Settings.Config.setTempOrder(order);
			onCreatedOrder(new EventArgs());
		}
Beispiel #10
0
        public ActionResult ApplicationForm(Models.ApplicantBasicViewModel applicantData, string ButtonType)
        {
            // return PartialView("Confirmation", app);

            Entity.Applicant currentApplicant = GetApplicant();

            if (ButtonType == "Reset")
            {
                var NewModel = new Models.ApplicantBasicViewModel();
                ModelState.Clear();
                return(View(NewModel));
            }



            if (ButtonType == "Back")
            {
                Models.GradeViewModel grade = new Models.GradeViewModel();
                grade.ID = SelectedGrade.ID;
                // grade.Grade = _unitOfWork.Grade_Infos.Find(grade.ID).Grade;
                return(View("GradeSelection", grade));
            }


            if (ButtonType == "Next")
            {
                if (ModelState.IsValid)
                {
                    currentApplicant.FName  = applicantData.FName; //To-Do use automapper
                    currentApplicant.MName  = applicantData.MName;
                    currentApplicant.LName  = applicantData.LName;
                    currentApplicant.DOB    = applicantData.DOB;
                    currentApplicant.Gender = applicantData.Gender;

                    Entity.Address address = new Entity.Address();
                    address.Email = applicantData.Contact_Email;
                    address.PhoneBooks.Add(new Entity.PhoneBook()
                    {
                        Type = "Mobile", Phone = applicantData.Contact_MobilePhone
                    });
                    address.PhoneBooks.Add(new Entity.PhoneBook()
                    {
                        Type = "Office", Phone = applicantData.Contact_OfficePhone
                    });

                    Entity.Contact contact = new Entity.Contact()
                    {
                        FName = applicantData.Contact_FName, MName = applicantData.Contact_MName, Address = address
                    };

                    currentApplicant.Contacts.Add(contact);



                    return(View("DocumentUpload", GetDocuments()));
                }
            }


            return(View());
        }