Example #1
0
        public void ConfirmNewNotebookName(string newNotebookName)
        {
            NewNotebookClicked = false;

            NotebookModel notebook = Notebooks.ToList <NotebookModel>().Find(n => n.Name == newNotebookName);

            if (notebook == null)
            {
                try
                {
                    DBDataAccessInsert.InsertNotebook(new NotebookModel()
                    {
                        UserId = User.Id,
                        Name   = newNotebookName
                    });

                    Notebooks.Clear();
                    Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id));
                }
                catch (SQLiteException)
                {
                    MessageBox.Show("Invalid Name");
                }
            }
            else
            {
                MessageBox.Show("Notebook with this name already exists");
            }
        }
Example #2
0
        public static void UpdateNotebook(NotebookModel notebook)
        {
            string           connectionString = ConfigurationManager.ConnectionStrings["NotesAppDB"].ConnectionString;
            SQLiteConnection connection       = new SQLiteConnection(connectionString);

            connection.Open();

            string cmd = $"update notebooks " +
                         $"set name = '{notebook.Name}' " +
                         $"where id = {notebook.Id}";
            SQLiteCommand command = new SQLiteCommand(cmd, connection);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
Example #3
0
        public void Execute(object parameter)
        {
            //Las notas se han de crear dentro de un notebook...
            NotebookModel selectedNotebook = parameter as NotebookModel;

            VM.CreateNote(selectedNotebook.Id);
        }
        // GET: Search
        public ActionResult Notebooks(NotebookModel model)
        {
            int pageIndex = model.Page ?? 1;

            using (EquipmentsEntities data = new EquipmentsEntities())
            {
                model.NotebookSearch = (from c in data.TB_Notebooks.Where(p => p.KayitDurum == "Active" && (String.IsNullOrEmpty(model.Users) || p.Users.Contains(model.Users)) &&
                                                                          (String.IsNullOrEmpty(model.SerialNumber) || p.SerialNum.Contains(model.SerialNumber))).OrderByDescending(p => p.ID)
                                        select new NotebookListModel
                {
                    EthMac = c.EthMac,
                    InvoiceNumber = c.InvoiceNumber,
                    OldUser = c.OldUser,
                    PcName = c.PcName,
                    SerialNum = c.SerialNum,
                    PurchaseDate = c.PurchaseDate,
                    Specification = c.Specification,
                    SSD = c.SSD,
                    SSDSerial = c.SSDSerial,
                    UserCode = c.UserCode,
                    Users = c.Users,
                    Vendor = c.Vendor,
                    WifiMac = c.WifiMac,
                    WindowsCdKey = c.WindowsCdKey
                }).ToPagedList(pageIndex, 15);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("_Notebook", model));
                }
                else
                {
                    return(View(model));
                }
            }
        }
        public void NotebookModel_Should_Set_Notebook()
        {
            var notebook = new Notebook();
            var model    = new NotebookModel();

            model.Notebook = notebook;

            Assert.AreSame(notebook, model.Notebook);
        }
Example #6
0
        public async void CreateNotebook()
        {
            NotebookModel notebook = new NotebookModel
            {
                UserId = _loggedInUserModel.Id,
                Name = $"New Notebook {numberOfNotebooks}"
            };
            await _notesEndPoint.PostNotebookInfo(notebook);

            await _events.PublishOnUIThreadAsync(new NotesEvent());
        }
Example #7
0
        public bool CanExecute(object parameter)
        {
            //Sólo podremos crear una nueva nota si hay un Notebook seleccionado..
            NotebookModel selectedNotebook = parameter as NotebookModel;

            if (selectedNotebook != null)
            {
                return(true);
            }

            return(false);
        }
        public async Task <int> PostNotebookInfo(NotebookModel notebook)
        {
            using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("/api/Notebook", notebook))
            {
                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    return(int.Parse(result));
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
        public int CreateNotebook(string storedProcedure, NotebookModel notebook, string connectionStringName)
        {
            string connectionString = GetConnectionString(connectionStringName);

            using (IDbConnection connection = new SqlConnection(connectionString))
            {
                var p = new DynamicParameters();
                p.Add("@UserId", notebook.UserId);
                p.Add("@Name", notebook.Name);
                p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute(storedProcedure,
                                   p, commandType: CommandType.StoredProcedure);

                int newId = p.Get <int>("@Id");
                return(newId);
            }
        }
Example #10
0
        public async void HasRenamed(NotebookModel notebook)
        {
            //Linkado con el command al perder el foco del textbox..Lo que significará que se ha terminado de editar
            //y se puede actualizar el nombre del Notebook...
            if (notebook != null)
            {
                //// DatabaseHelper.Update(notebook);
                try
                {
                    await App.MobileServiceClient.GetTable <NotebookModel>().UpdateAsync(notebook);

                    IsEditing = false;
                    ReadNotebooks();
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #11
0
        public async void CreateNotebook()
        {
            NotebookModel newNotebook = new NotebookModel()
            {
                Name   = "New notebook",
                UserId = App.UserId
            };

            //DatabaseHelper.Insert(newNotebook);

            try
            {
                await App.MobileServiceClient.GetTable <NotebookModel>().InsertAsync(newNotebook);
            }
            catch (Exception ex)
            {
            }
            ReadNotebooks();
        }
Example #12
0
        public static void InsertNotebook(NotebookModel notebook)
        {
            string           connectionString = ConfigurationManager.ConnectionStrings["NotesAppDB"].ConnectionString;
            SQLiteConnection connection       = new SQLiteConnection(connectionString);

            connection.Open();

            string cmd = "insert into notebooks (userId, name)" +
                         $"values ({notebook.UserId}, '{notebook.Name}')";
            SQLiteCommand command = new SQLiteCommand(cmd, connection);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
 public int Post(NotebookModel notebook)
 {
     return(_notebookData.InsertNotebook(notebook));
 }
Example #14
0
        public void Execute(object parameter)
        {
            NotebookModel notebook = parameter as NotebookModel;

            VM.HasRenamed(notebook);
        }
        public int InsertNotebook(NotebookModel notebook)
        {
            int newNotebookId = _sql.CreateNotebook("dbo.spNotebook_Insert", notebook, "TulipData");

            return(newNotebookId);
        }