//Loading filtered data
 private void LoadData(string name)
 {
     using (var db = new ApirsRepository <tblCuboid>())
     {
         try
         {
             Cuboids = new BindableCollection <tblCuboid>(db.GetModelByExpression(cub => cub.cubLabel == name));
             if (Cuboids.Count == 0)
             {
                 SelectedCuboid          = new tblCuboid();
                 SelectedCuboid.cubLabel = name;
             }
             else if (Cuboids.Count > 1)
             {
                 SelectedCuboid = Cuboids.First();
             }
             else
             {
                 SelectedCuboid = Cuboids.First();
             }
         }
         catch
         {
             Cuboids        = new BindableCollection <tblCuboid>();
             SelectedCuboid = new tblCuboid();
         }
     }
 }
 public void Update()
 {
     using (var db = new ApirsRepository <tblCuboid>())
     {
         try
         {
             if (SelectedCuboid.cubIdPk == 0)
             {
                 try
                 {
                     db.InsertModel(SelectedCuboid);
                     db.Save();
                     TryClose();
                 }
                 catch
                 {
                     ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Cuboid can't be added. Please check every field again.");
                     return;
                 }
             }
             else
             {
                 tblCuboid result = db.GetModelById(SelectedCuboid.cubIdPk);
                 if (result != null)
                 {
                     db.UpdateModel(SelectedCuboid, SelectedCuboid.cubIdPk);
                     db.Save();
                 }
             }
         }
         catch (SqlException ex)
         {
             ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters");
         }
         catch (Exception e)
         {
             ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Something went wrong");
         }
         finally
         {
         }
     }
 }