예제 #1
0
 public ActionResult CreatePost()
 {
     service.AddElement(new ElementBindingModel
     {
         ElementName = Request["ElementName"]
     });
     return(RedirectToAction("Index"));
 }
예제 #2
0
        public ActionResult Create(ElementAddViewModel viewmodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = Mapper.Map <ElementAddViewModel, Element>(viewmodel);
                    _elementService.AddElement(entity);

                    Success($"<strong>{entity.DisplayName}</strong> was successfully added.");
                    return(RedirectToAction("Index"));
                }
                return(View(viewmodel));
            }
            catch
            {
                return(View(viewmodel));
            }
        }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxComponent.Text))
     {
         MessageBox.Show("Заполните компонент", "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     try
     {
         if (id.HasValue)
         {
             service.UpdElement(new ElementBindingModel
             {
                 Id          = id.Value,
                 ElementName = textBoxComponent.Text
             });
         }
         else
         {
             service.AddElement(new ElementBindingModel
             {
                 ElementName = textBoxComponent.Text
             });
         }
         MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }