public ActionResult UpdateAddress(Addres model, int addressID) { DatabaseContext databaseContext = new DatabaseContext(); Person person = databaseContext.People.Where(x => x.PersonId == model.PersonId).FirstOrDefault(); Addres address = databaseContext.Addreses.Where(x => x.AddressId == addressID).FirstOrDefault(); if (addressID > 0) { address.AddressDefinition = model.AddressDefinition; address.Person = person; } int result = databaseContext.SaveChanges(); if (result > 0) { ViewBag.Result = "Adres güncellenmiştir.."; ViewBag.Status = "success"; } else { ViewBag.Result = "Adres güncellenememiştir"; ViewBag.Status = "danger"; } ViewBag.People = TempData["people"]; return(View(model)); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { if (_studentRepository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } if (_studentRepository.EmailExists(command.Email)) { AddNotification("Email", "Este e-mail já está em uso"); } var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Addres(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payerDocument = new Document(command.PayerDocument, command.PayerDocumentType); var payment = new PayPalPayment(command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, payerDocument, command.Payer, address, email); subscription.AddPayment(payment); student.AddSubscription(subscription); AddNotifications(name, document, email, address, student, subscription, payment); _studentRepository.CreateSubscription(student); _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada"); return(new CommandResult(true, "Assinatura Realizada com Sucesso")); }
public ActionResult AddAddres(Addres addres) { DatabaseContext databaseContext = new DatabaseContext(); addres.IsActive = true; Person person = databaseContext.People.Where(x => x.PersonId == addres.Person.PersonId).FirstOrDefault(); if (person != null) { addres.Person = person; databaseContext.Addreses.Add(addres); int result = databaseContext.SaveChanges(); if (result > 0) { ViewBag.Result = "Adres kaydedilmişitir."; ViewBag.Status = "success"; } else { ViewBag.Result = "Adres kaydedilemedi."; ViewBag.Status = "danger"; } } ViewBag.People = TempData["people"]; return(View()); }
/// <summary> /// Генерация запроса, для добавления одной записи /// </summary> /// <returns></returns> public Addres getOneRecord() { Random rnd = new Random(); int indCity = 0; // сгенерированный индекс города int indStreet = 0; // сгенерированный индекс улицы int numHouse = 1; // номер дома int index = 111111; // индекс Addres rec = new Addres(); List <string> lCountry = new List <string>(); List <string> lCity = new List <string>(); List <string> lStreet = new List <string>(); lCountry = getCountry(); //получим список стран lCity = getCity(); //получим список городов lStreet = getStreet(); //получим список улиц indCity = rnd.Next(0, lCity.Count - 1); indStreet = rnd.Next(0, lStreet.Count - 1); index = rnd.Next(111111, 1000000); numHouse = rnd.Next(1, 301); rec.Id = 0; rec.Country = lCountry[0]; rec.City = lCity[indCity]; rec.Street = lStreet[indStreet]; rec.Number = numHouse; rec.Index = index; rec.Date = DateTime.Now; return(rec); }
protected override void Seed(DatabaseContext context) { for (int i = 0; i < 10; i++) { Person person = new Person(); person.PersonName = FakeData.NameData.GetMaleFirstName(); person.PersonSurname = FakeData.NameData.GetFirstName(); person.PersonAge = FakeData.NumberData.GetNumber(10, 50); context.People.Add(person); } context.SaveChanges(); List <Person> people = context.People.ToList(); foreach (var item in people) { for (int i = 0; i < FakeData.NumberData.GetNumber(1, 5); i++) { Addres addres = new Addres(); addres.AddressDefinition = FakeData.PlaceData.GetAddress(); addres.Person = item; context.Addreses.Add(addres); } context.SaveChanges(); } }
public StudentTests() { name = new Name("Luiz", "Fernando"); document = new Document("12345678921", EDocumentType.CPF); email = new Email("*****@*****.**"); address = new Addres("Rua Teste", "61", "86170000", "Sertanopolis", "PR", "Brasil", "1340000"); student = new Student(name, document, email); subscription = new Subscription(null); }
public void getOneRecordTest() { //Arrange string appDataPath = Environment.CurrentDirectory; GeneratorData gd = new GeneratorData(appDataPath); //Act Addres adr = gd.getOneRecord(); //Assert Assert.IsNotNull(adr); }
static void Main(string[] args) { Addres addres = new Addres(); addres.index = 000000; addres.country = "Country"; addres.street = "Street"; addres.house = 1; addres.apartment = 1; addres.GetInfo(); Console.ReadKey(); }
private int InsertAddresReturnID(RetnsViewModels rentV, int cityDropDown) { var address = new Addres() { City_ID = cityDropDown, District_ID = rentV.District_ID, Flat = rentV.Flat, Street = rentV.Street }; _addressRep.Create(address); _addressRep.Save(); return(address.Addres_ID);; }
public void FillRegistrationForm(UserModel user) { Gender(user.Gender).Click(); FirstName.TypeText(user.FirstName); LastName.TypeText(user.LastName); Password.TypeText(user.Password); DayOfBirth.WrappedElement.SendKeys(user.DayOfBirth); new SelectElement(MonthOfBirth.WrappedElement).SelectByValue(user.MonthOfBirth); YearOfBirth.WrappedElement.SendKeys(user.YearOfBirth); Addres.TypeText(user.Addres); City.TypeText(user.City); new SelectElement(State.WrappedElement).SelectByValue(user.State.ToString()); PostalCode.TypeText(user.PostalCode.ToString()); MobilePhone.TypeText(user.MobilePhone); SubmitButton.Click(); }
protected Payment(DateTime paidDate, DateTime expireDate, decimal total, decimal totalPaid, Document document, string payer, Addres address, Email email) { Number = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10).ToUpper(); PaidDate = paidDate; ExpireDate = expireDate; Total = total; TotalPaid = totalPaid; Document = document; Payer = payer; Address = address; Email = email; AddNotifications(new Contract() .Requires() .IsLowerOrEqualsThan(0, Total, "Payment.Total", "O total não pode ser zero") .IsGreaterOrEqualsThan(Total, TotalPaid, "Payment.TotalPaid", "O valor pago é menor que do pagamento") ); }
public ActionResult UpdateAddress(int addressID) { DatabaseContext databaseContext = new DatabaseContext(); //List<SelectListItem> peopleList = // (from person in databaseContext.People.ToList() // select new SelectListItem() // { // Text = person.PersonName + " " + person.PersonSurname, // Value = person.PersonId.ToString() // } // ).ToList(); var peopleList = databaseContext.People.Where(x => x.IsActive == true).ToList(); TempData["people"] = peopleList; ViewBag.People = peopleList; Addres address = databaseContext.Addreses.Where(x => x.AddressId == addressID).FirstOrDefault(); return(View(address)); }
public ActionResult Create(ClientViewModels clientV, int?cityDropDown) { try { var address = new Addres() { City_ID = cityDropDown, District_ID = clientV.District_ID, Flat = clientV.Flat, Street = clientV.Street }; _addressRep.Create(address); _addressRep.Save(); var addressId = address.Addres_ID; var client = new Client() { Name = clientV.Name, Surname = clientV.Surname, Email = clientV.Email, Idnp = clientV.Idnp, Phone = clientV.Phone, Addres_ID = addressId, }; _clientRep.Create(client); _clientRep.Save(); return(RedirectToAction("Index")); } catch (Exception e) { return(View(e)); } }
public BoletoPayment(string barCode, string boletoNumber, DateTime paidDate, DateTime expireDate, decimal total, decimal totalPaid, Document document, string payer, Addres address, Email email) : base(paidDate, expireDate, total, totalPaid, document, payer, address, email) { BarCode = barCode; BoletoNumber = boletoNumber; }
public CreditCardPayment(string cardHolderName, string cardNumber, string lastTransactionNumber, DateTime paidDate, DateTime expireDate, decimal total, decimal totalPaid, Document document, string payer, Addres address, Email email) : base(paidDate, expireDate, total, totalPaid, document, payer, address, email) { CardHolderName = cardHolderName; CardNumber = cardNumber; LastTransactionNumber = lastTransactionNumber; }
public PayPalPayment(string transactionCode, DateTime paidDate, DateTime expireDate, decimal total, decimal totalPaid, Document document, string payer, Addres address, Email email) : base(paidDate, expireDate, total, totalPaid, document, payer, address, email) { TransactionCode = transactionCode; }
private void button1_Click(object sender, RoutedEventArgs e) { if (textBox1.Text != "") { if (textBox8.Text != "" && textBox9.Text != "") { int Type_ID = 0, Categ_ID = 0; int Address_ID; try { /*SqlConnection con = new SqlConnection(Data.value); * con.Open();*/ //Получаю id типа воды //try //{ var reader = from type in dbContex.type where type.Название == comboBox1.SelectedItem.ToString() select type.id_type; foreach (var item in reader) { Type_ID = (int)item; System.Windows.Forms.MessageBox.Show("ID Типа " + item.ToString()); } if (getAdderss_ID(textBox8.Text, textBox9.Text) == -1) { Addres addr = new Addres { Широта = textBox8.Text, Долгота = textBox9.Text }; dbContex.Addres.InsertOnSubmit(addr); // Submit the change to the database. try { dbContex.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } //Повторно отправляю запрос и получаю id Адреса Address_ID = getAdderss_ID(textBox8.Text, textBox9.Text); //Получаю id категории воды var ID_Categs = from Category in dbContex.Category where Category.Название == comboBox1.SelectedItem.ToString() select Category.id_categ; foreach (var item in ID_Categs) { Categ_ID = (int)item; System.Windows.Forms.MessageBox.Show("ID Категории " + item.ToString()); } /*SqlConnection con = new SqlConnection(Data.value); * con.Open(); * string query = "INSERT INTO Prob_water (Название, Дата_забора, Консервация, Объем, id_Address, id_type, id_categ) VALUES(@Name, @Date, @Conserv, @V, @Address, @type, @categ)"; * SqlCommand cmd = new SqlCommand(query, con); * cmd.Parameters.AddWithValue("@Name", textBox1.Text); * cmd.Parameters.AddWithValue("@Date", Convert.ToDateTime(textBox2.Text)); * cmd.Parameters.AddWithValue("@Conserv", comboBox2.SelectedItem.ToString()); * cmd.Parameters.AddWithValue("@V", textBox.ToString()); * cmd.Parameters.AddWithValue("@Address", Address_ID); * cmd.Parameters.AddWithValue("@type", Type_ID); * cmd.Parameters.AddWithValue("@categ", Categ_ID); * cmd.ExecuteNonQuery(); * con.Close();*/ //DateTime dt = DateTime.ParseExact(textBox2.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture); //DateTime dot = Convert.ToDateTime(textBox2.Text).Date; //string s = dt.ToString("dd.M.yyyy", CultureInfo.InvariantCulture); //DateTime ndt = dt.Date; //MessageBox.Show(ndt.ToString("d")); Prob_water newProb = new Prob_water { Название = textBox1.Text, Дата_забора = Convert.ToDateTime(textBox2.Text), Консервация = comboBox2.SelectedItem.ToString(), Объем = textBox.ToString(), id_Address = Address_ID, id_type = Type_ID, id_categ = Categ_ID }; dbContex.Prob_water.InsertOnSubmit(newProb); // Submit the change to the database. try { dbContex.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //string queryType = "SELECT * FROM type WHERE Название='" + comboBox1.SelectedItem.ToString() + "'"; /*SqlCommand comm = new SqlCommand(queryType, con); * using (var read = comm.ExecuteReader()) * { * while (read.Read()) * { * type = (int)read.GetValue(0); * } * }*/ //} //catch //{ //System.Windows.Forms.MessageBox.Show("Введите тип воды"); //con.Close(); // return; //} //Получаю id Адреса //Если запрос ничего не вернул заношу в таблицу координаты /* string queryAddressId = "SELECT id_Address FROM Addres WHERE Широта = '" + textBox8.Text + "' AND Долгота = '" + textBox9.Text+"'"; * SqlCommand comm2 = new SqlCommand(queryAddressId, con); * try * { * using (var read = comm2.ExecuteReader()) * { * while (read.Read()) * { * idAddress += (int)read.GetValue(0); * } * } * } * catch * { * System.Windows.Forms.MessageBox.Show("Не получил id запрос"); * con.Close(); * return; * } * * //Если запрос ничего не вернул заношу в таблицу координаты * if (idAddress == -1) * { * string queryAddress = "INSERT INTO Addres (Широта, Долгота) VALUES (@latitude, @longitude)"; * SqlCommand comm = new SqlCommand(queryAddress, con); * comm.Parameters.AddWithValue("@latitude", textBox8.Text); * comm.Parameters.AddWithValue("@longitude", textBox9.Text); * comm.ExecuteNonQuery(); * } * //Повторно отправляю запрос и получаю id Адреса * try * { * using (var read = comm2.ExecuteReader()) * { * while (read.Read()) * { * idAddress = (int)read.GetValue(0); * } * } * } * catch * { * System.Windows.Forms.MessageBox.Show("Не получил id адреса после занесения новых координат"); * con.Close(); * return; * } * * * //Получаю id категории воды * try * { * string queryCateg = "SELECT id_categ FROM Category WHERE Название='" + comboBox.SelectedItem.ToString() + "'"; * SqlCommand comm = new SqlCommand(queryCateg, con); * using (var read = comm.ExecuteReader()) * { * while (read.Read()) * { * categ = (int)read.GetValue(0); * } * } * } * catch * { * System.Windows.Forms.MessageBox.Show("Введите категорию воды"); * con.Close(); * return; * } * if (categ == 0) * { * System.Windows.Forms.MessageBox.Show("Ничего не получилось категория не вернулась"); * con.Close(); * return; * } * if (type == 0) * { * System.Windows.Forms.MessageBox.Show("Ничего не получилось тип не вернулся"); * con.Close(); * return; * } * string query = "INSERT INTO Prob_water (Название, Дата_забора, Консервация, Объем, id_Address, id_type, id_categ) VALUES(@Name, @Date, @Conserv, @V, @Address, @type, @categ)"; * SqlCommand cmd = new SqlCommand(query, con); * cmd.Parameters.AddWithValue("@Name", textBox10.Text); * cmd.Parameters.AddWithValue("@Date", textBox2.Text); * cmd.Parameters.AddWithValue("@Conserv", comboBox2.SelectedItem.ToString()); * cmd.Parameters.AddWithValue("@V", textBox.ToString()); * cmd.Parameters.AddWithValue("@Address", idAddress); * cmd.Parameters.AddWithValue("@type", type); * cmd.Parameters.AddWithValue("@categ", categ); * cmd.ExecuteNonQuery(); * con.Close();*/ } catch (Exception ex) { throw new Exception(ex.ToString(), ex); } } else { System.Windows.Forms.MessageBox.Show("Не введены координаты"); } } else { System.Windows.Forms.MessageBox.Show("Не введено имя пробы"); } }
private void CancelButtonClick(object sender, RoutedEventArgs e) { Addres.SetValues(preEditAddress); NotifyPropertyChanged("Addres"); EditMode = false; }
private void EditButtonClick(object sender, RoutedEventArgs e) { preEditAddress = (Address)Addres.Clone(); EditMode = true; }