Пример #1
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in drepturiGrid.Rows)
     {
         var drept = (Drept)row.DataBoundItem;
         var areDrept = row.Cells["check"].Value;
         var rolDrept = RolDrept.GetAll().Where(p => p.IdDrept == drept.ID && p.IdRol == RolObject.ID).FirstOrDefault();
         if (rolDrept == null)
         {
             rolDrept = new RolDrept();
             rolDrept.IdRol = RolObject.ID;
             rolDrept.IdDrept = drept.ID;
         }
         if (areDrept == null)
         {
             rolDrept.AreDrept = false;
         }
         else
         {
             rolDrept.AreDrept = (bool)areDrept;
         }
         var result = rolDrept.Save();
         if (row.Index == drepturiGrid.Rows.Count - 1)
         {
             MessageBox.Show(result.Message);
             if (result.Status == StatusEnum.Saved)
             {
                 DialogResult = DialogResult.OK;
             }
         }
     }
 }
Пример #2
0
 public void InsertRolDreptTest()
 {
     var target = new RolDrept
     {
         IdDrept = 1,
         IdRol = 1,
         AreDrept=true
     };
     if (target.Save().Status == StatusEnum.Errors)
     {
         Assert.Fail();
     }
 }
Пример #3
0
 public void UpdateRolDreptTest()
 {
     var target = new RolDrept
     {
         IdDrept = 1,
         IdRol = 2,
         AreDrept=false,
         ID=1
     };
     if (target.Save().Status == StatusEnum.Errors)
     {
         Assert.Fail();
     }
 }