public ActionResult Subscribe(SubscribeModel model) { if (ModelState.IsValid) { //TODO: SubscribeUser(model.Email); } return(View("Index", model)); }
private void Button1_Click(object sender, EventArgs e) { subscribeModel = new SubscribeModel(textBoxNumber.Text, textBoxInn.Text, textBoxAddress.Text); if (subscribeModel.validate(errorNumber, errorINN, errorAddress)) { Cursor.Current = Cursors.WaitCursor; sqlConnection = new SqlConnection(con); if (ValidateController.validateItem(idSubscriber.Text)) { commandString = $@"UPDATE [dbo].[Subscribers] SET [NumberPhone] = '{subscribeModel.MobilePhone}' ,[INN] = '{subscribeModel.INN}' ,[Address] = '{subscribeModel.Address}' WHERE IdSubscriber = '{idSubscriber.Text}'" ; } else { commandString = $@"INSERT INTO [dbo].[Subscribers] ([NumberPhone] ,[INN] ,[Address]) VALUES( '{subscribeModel.MobilePhone}', '{subscribeModel.INN}', '{subscribeModel.Address}')" ; } try { sqlConnection.Open(); } catch (Exception) { MessageBox.Show("Не удалось подключиться"); } command = new SqlCommand(commandString, sqlConnection); command.ExecuteNonQuery(); this.subscribersTableAdapter2.Fill(this.phoneCallDataSet15.Subscribers); idSubscriber.Text = ""; ValidateController.CleanerTextBox(textBoxAddress, textBoxInn, textBoxNumber); Cursor.Current = Cursors.Default; } else { MessageBox.Show("Заполните данные"); } }