public GroupCreditWorthinesViewModel(GroupCreditWorthiness model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            this.model = model;
        }
Example #2
0
 // Добавление группы
 public int AddGroupCreditWorthiness(GroupCreditWorthiness model)
 {
     using (DataContext cntx = new DataContext())
     {
         try
         {
             cntx.Entry(model).State = EntityState.Added;
             cntx.SaveChanges(); // сохранение добавления
         }
         catch (Exception) { return(0); }
     }
     return(model.Id);
 }
Example #3
0
 // Редактирование группы
 public bool UpdateGroupCreditWorthiness(GroupCreditWorthiness model)
 {
     using (DataContext cntx = new DataContext())
     {
         try
         {
             GroupCreditWorthiness oldModel = cntx.GroupCreditWorthinesss.FirstOrDefault(x => x.Id == model.Id);
             cntx.Entry(oldModel).CurrentValues.SetValues(model); // копируем изменения из model в oldModel
             cntx.SaveChanges();
         }
         catch (Exception) { return(false); }
     }
     return(true);
 }
Example #4
0
 // удаление группы
 public bool DeleteGroupCreditWorthiness(GroupCreditWorthiness model)
 {
     using (DataContext cntx = new DataContext())
     {
         try
         {
             GroupCreditWorthiness modelDel = cntx.GroupCreditWorthinesss.FirstOrDefault(x => x.Id == model.Id);
             cntx.Entry(modelDel).State = EntityState.Deleted;
             cntx.SaveChanges(); // сохранение удаления
         }
         catch (Exception) { return(false); }
     }
     return(true);
 }
Example #5
0
        private void AddModel()
        {
            GroupCreditWorthiness       model = new GroupCreditWorthiness();
            AddGroupCreditWorthinesView view  = new AddGroupCreditWorthinesView(true, model, repository)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();

            if (view.DialogResult != true)
            {
                return;
            }

            model.Id = repository.AddGroupCreditWorthiness(model);
            if (model.Id == 0)
            {
                MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Add(new GroupCreditWorthinesViewModel(model));
        }