public ActionResult AddElementPost()
        {
            var output     = (OutputViewModel)Session["Output"];
            var ingredient = new OutputElementViewModel
            {
                ElementId   = int.Parse(Request["ElementId"]),
                ElementName = ingredientService.GetElement(int.Parse(Request["ElementId"])).ElementName,
                Number      = int.Parse(Request["Number"])
            };

            output.OutputElements.Add(ingredient);
            Session["Output"] = output;
            return(RedirectToAction("Index"));
        }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxCount.Text))
     {
         MessageBox.Show("Заполните поле Количество", "Ошибка",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (comboBoxComponent.SelectedValue == null)
     {
         MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     try
     {
         if (model == null)
         {
             model = new OutputElementViewModel
             {
                 ElementId   = Convert.ToInt32(comboBoxComponent.SelectedValue),
                 ElementName = comboBoxComponent.Text,
                 Number      = Convert.ToInt32(textBoxCount.Text)
             };
         }
         else
         {
             model.Number = Convert.ToInt32(textBoxCount.Text);
         }
         MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }