public void UpdateNotes([FromBody] NotesModel notesModel, int id)
 {
     try
     {
         NotesModel tableModel = this.context.Notes.Where <NotesModel>(t => t.Id == id).FirstOrDefault();
         tableModel.Title     = notesModel.Title;
         tableModel.TakeANote = notesModel.TakeANote;
         tableModel.IsPin     = notesModel.IsPin;
         tableModel.IsArchive = notesModel.IsArchive;
         tableModel.IsTrash   = notesModel.IsTrash;
         tableModel.ColorCode = notesModel.ColorCode;
         tableModel.ImageUrl  = notesModel.ImageUrl;
         tableModel.Reminder  = notesModel.Reminder;
         int result = 0;
         try
         {
             result = this.context.SaveChanges();
         }
         catch (Exception e)
         {
             e.ToString();
         }
     }
     catch (Exception e)
     {
         e.ToString();
     }
 }
Esempio n. 2
0
        public void Insert(NotesModel notes)
        {
            var sql        = "INSERT INTO public.notes (notes, favorited_id, user_id) VALUES (@notes, @favorited_id, @user_id)";
            var parameters = notes;

            _postgreSQL.Insert(sql, parameters);
        }
Esempio n. 3
0
        public IActionResult UpdateNote([FromBody] NotesModel note)
        {
            try
            {
                var result = this.notes.UpdateNote(note);
                if (result == true)
                {
                    return(this.Ok(new ResponseModel <NotesModel>()
                    {
                        Status = true, Message = "Note updated Successfully !", Data = note
                    }));
                }

                return(this.BadRequest(new ResponseModel <NotesModel>()
                {
                    Status = false, Message = "Error While updating note"
                }));
            }
            catch (Exception ex)
            {
                return(this.NotFound(new ResponseModel <NotesModel>()
                {
                    Status = false, Message = ex.Message
                }));
            }
        }
Esempio n. 4
0
        public object GetNotes(string Email)
        {
            var list        = new List <NotesModel>();
            var label       = new List <LableTbl>();
            var SharingNote = new List <CollaboratorTbl>();
            var Label       = from t in context.tblLabel where t.Email == Email select t;

            foreach (var lbl in Label)
            {
                label.Add(lbl);
            }
            GetNotesData data      = new GetNotesData();
            var          Notesdata = from t in context.Notes where t.Email == Email select t;

            foreach (var item in Notesdata)
            {
                list.Add(item);
            }
            var collaborator = from t in context.tblCollaborator where t.SharedId == Email select t;

            foreach (var emaildata in collaborator)
            {
                var        noteid = emaildata.ID;
                NotesModel note   = context.Notes.Where <NotesModel>(t => t.Id == noteid).First();
                list.Add(note);
            }
            data.noteData = list;
            data.label    = label;
            return(data);
        }
Esempio n. 5
0
        public async Task <IActionResult> AddNotes(NotesModel notesModel)
        {
            try
            {
                _logger.LogInformation("Could break here :(");
                ////BusinessLayer method call
                var result = await _businessManager.AddNotes(notesModel);

                ////if result is null then it throw the error message
                if (!result.Equals(null))
                {
                    return(this.Ok(new { result }));
                }
                else
                {
                    return(this.BadRequest(new { Message = "Notes not added" }));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(e, "It broke :(");
                Console.WriteLine(ex.Message);
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// Add the notes.
        /// </summary>
        /// <param name="notesModel">The notes model.</param>
        /// <returns>return result.</returns>
        public async Task <int> AddNotes(NotesModel notesModel)
        {
            ////RepositoryManager layer method called
            var result = await this.repositoryManager.AddNotes(notesModel);

            return(result);
        }
Esempio n. 7
0
 public IActionResult UpdateCollaborator(int noteId, int id, NotesModel notesModel)
 {
     try
     {
         if (!id.Equals(null))
         {
             ////BusinessManager layer method call
             var result = this._businessManager.UpdateCollaborator(noteId, id, notesModel);
             if (!result.Equals(null))
             {
                 ////return the result.
                 return(this.Ok(new { result }));
             }
             else
             {
                 return(this.BadRequest(new { message = "The collaborator is not updated successfuly" }));
             }
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Esempio n. 8
0
        public IActionResult Notes([FromBody] NotesModel notes)
        {
            try
            {
                var is_successed = this.notes.AddNewNote(notes);
                if (is_successed == true)
                {
                    return(this.Ok(new ResponseModel <NotesModel>()
                    {
                        Status = true, Message = "New Note added Successfully!", Data = notes
                    }));
                }

                return(this.BadRequest(new ResponseModel <NotesModel>()
                {
                    Status = false, Message = "Failed to Add New Note to Database"
                }));
            }
            catch (Exception ex)
            {
                return(this.NotFound(new ResponseModel <NotesModel>()
                {
                    Status = false, Message = ex.Message
                }));
            }
        }
        /// <summary>
        /// Udate existing Notes in client model session
        /// </summary>
        /// <param name="model">Existing Notes instance to update</param>
        /// <returns>Returns true if updating was succesfull. Otherwise false.</returns>
        public bool UpdateNotesToClientModelSession(NotesModel model)
        {
            ClientFullModel fullModel = GetFullModelFromClientModel();

            if (fullModel != null)
            {
                var record = fullModel.Opombe.Where(n => n.idOpombaStranka == model.idOpombaStranka).FirstOrDefault();
                if (record != null)
                {
                    int index = fullModel.Opombe.IndexOf(record);
                    if (index != -1)
                    {
                        fullModel.Opombe[index] = model;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                AddValueToSession(Enums.ClientSession.ClientModel, fullModel);

                return(true);
            }
            return(false);
        }
Esempio n. 10
0
        public async Task <IActionResult> DeleteNotes(NotesModel obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ClaimsIdentity claimsIdentity        = User.Identity as ClaimsIdentity;
                    var            currentLoginUserid    = new UserClaims(claimsIdentity).LoggedInUserId;
                    var            currentLoginUserOrgid = new UserClaims(claimsIdentity).OrgId;
                    obj.createdBy = currentLoginUserid;
                    using (var uow = new UnitOfWork(_configs.Value.DbConnectionString))
                    {
                        await uow.Notes.deleteNotesAsync(obj.noteId, obj.createdBy);

                        uow.Commit();
                        return(Ok(new ApiResponse {
                            message = ApiMessageConstants.commonDeleted
                        }));
                    }
                }
                else
                {
                    return(BadRequest(new ApiResponse {
                        message = ApiMessageConstants.someThingWentWrong
                    }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new ApiResponse {
                    message = ex.Message
                }));
            }
        }
Esempio n. 11
0
        public ActionResult AddNote(NotesModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Note))
            {
                ViewBag.error = "Empty Note";
                return(View("NoteList", getNotesViewModel()));
            }

            NotesData notesData = new NotesData();

            notesData.UserID   = Convert.ToInt32(Session["userid"]);
            notesData.UserNote = model.Note;
            notesData.NoteID   = model.NoteID;

            try
            {
                ((IPersistable)notesData).Save();
            }
            catch (Exception ex)
            {
                ViewBag.error = "Error in Save : " + ex.ToString();
                return(View("NoteList", getNotesViewModel()));
            }

            return(View("NoteList", getNotesViewModel()));
        }
        /// <summary>
        /// update the collaborator data.
        /// </summary>
        /// <param name="noteId">note id</param>
        /// <param name="id">collaborator id.</param>
        /// <param name="notesModel">notes model data.</param>
        /// <returns>return the result.</returns>
        public async Task <int> UpdateCollaborator(int noteId, int id, NotesModel notesModel)
        {
            try
            {
                if (!notesModel.Equals(null) && !id.Equals(null) && !noteId.Equals(null))
                {
                    ////repositoryManager Layer method.
                    var result = await this.repositoryManager.UpdateCollaborator(noteId, id, notesModel);

                    if (!result.Equals(null))
                    {
                        return(result);
                    }
                    else
                    {
                        throw new Exception("collaborator is not successfully updated");
                    }
                }
                else
                {
                    throw new Exception("note id or collaborator id or notes model data are null");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 13
0
        public void AddNoteWithModelToTestAddNoteFeature()
        {
            try
            {
                var repository = new Mock <INotesRepository>();

                var        controller = new NotesController(authenticationContext, repository.Object);
                NotesModel notesModel = new NotesModel()
                {
                    Title      = "Testing",
                    ColorCode  = "dsd",
                    Email      = "dadsa",
                    Id         = new Guid(),
                    ImageUrl   = "test",
                    IsArchieve = true,
                    IsPin      = false,
                    IsTrash    = false,
                    Reminder   = "dadsa",
                    TakeANote  = "asdfds"
                };

                var result = controller.PostNotes(notesModel);

                Assert.NotNull(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 14
0
        public async Task <long> AddAsync(NotesModel entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException();
            }
            if (string.IsNullOrWhiteSpace(entry.Title))
            {
                throw new ArgumentException("Title musn't be empty", nameof(entry.Title));
            }
            if (string.IsNullOrWhiteSpace(entry.Content))
            {
                throw new ArgumentException("Content musn't be empty", nameof(entry.Content));
            }
            if (entry.Title.Length > 1024)
            {
                throw new ArgumentException("Title mustn't be greater than 1024 characters", nameof(entry.Title));
            }
            if (entry.Content.Length > 1024 * 1024)
            {
                throw new ArgumentException("Content mustn't be greater than 1Mb", nameof(entry.Content));
            }

            entry.Id      = repository.Count;
            entry.Created = DateTime.UtcNow;
            repository.Add(entry.Id, entry);
            return(await Task.FromResult(entry.Id));
        }
Esempio n. 15
0
        public static void LoadMockData(this IEntryStore store)
        {
            NotesModel a = new NotesModel
            {
                Title = "Sprint Planning Meeting",
                Text  = "1. Scope 2. Backlog 3. Duration"
            };

            NotesModel b = new NotesModel
            {
                Title = "Daily Scrum Stand-up",
                Text  = "1. Yesterday 2. Today 3. Impediments"
            };

            NotesModel c = new NotesModel
            {
                Title = "Sprint Retrospective",
                Text  = "1. Reflection 2. Actions"
            };

            Task.WhenAll(
                store.AddAsync(a),
                store.AddAsync(b),
                store.AddAsync(c))
            .ConfigureAwait(false);
        }
 public EditNotePageViewModel(NotesModel model)
 {
     Text              = model.Text;
     Title             = model.Title;
     SelectedTextColor = model.TextColor;
     Note              = model;
 }
Esempio n. 17
0
        public ActionResult Add(NotesModel model)
        {
            //if model contains value for ID then edit record or create new record
            using (entity.encoraEntities context = new entity.encoraEntities())
            {
                entity.note note = null;
                if (model.ID > 0)
                {
                    note             = context.notes.Where(o => o.id == model.ID).FirstOrDefault();
                    note.description = model.Description;
                    note.isArchived  = model.isArchived;
                    note.modified    = DateTime.Now;
                    ViewBag.Message  = "Data updated successfully";
                }
                else
                {
                    note = context.notes.Create();

                    note.description = model.Description;
                    note.userID      = Convert.ToInt32(Session["UserID"]);
                    note.created     = DateTime.Now;
                    note.modified    = DateTime.Now;
                    note.isArchived  = model.isArchived;
                    context.notes.Add(note);
                    ViewBag.Message = "Data insert successfully";
                }

                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// AddNotes method is for adding the notes to the databaase
        /// </summary>
        /// <param name="notesModel">notes model.</param>
        /// <returns>return result.</returns>
        public async Task <int> AddNotes(NotesModel notesModel)
        {
            NotesModel note = new NotesModel()
            {
                UserId       = notesModel.UserId,
                Title        = notesModel.Title,
                Description  = notesModel.Description,
                Color        = notesModel.Color,
                Reminder     = notesModel.Reminder,
                CreatedDate  = notesModel.CreatedDate,
                ModifiedDate = notesModel.ModifiedDate,
                noteType     = notesModel.noteType,
                IsPin        = notesModel.IsPin
            };

            try
            {
                this.context.Notes.Add(note);
                int result = await this.context.SaveChangesAsync();

                if (result > 0)
                {
                    return(result);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 19
0
        public IActionResult Upsert([FromBody] NotesDto notesDto)
        {
            try
            {
                var note = new NotesModel()
                {
                    id           = notesDto.id,
                    notes        = notesDto.notes,
                    favorited_id = notesDto.favorited_id,
                    user_id      = notesDto.user_id
                };

                if (notesDto.id == 0)
                {
                    _notesRepository.Insert(note);
                }
                else
                {
                    _notesRepository.Update(note.id, notesDto.notes);
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
Esempio n. 20
0
        private NotesViewModel getNotesViewModel()
        {
            NotesViewModel notesViewModel = new NotesViewModel();

            notesViewModel.NotesList = null;
            List <NotesData> objNotes = NotesData.GetNoteList(Convert.ToInt32(Session["userid"]));

            if (objNotes != null)
            {
                for (int i = 0; i < objNotes.Count; i++)
                {
                    NotesModel notesModel = new NotesModel();
                    notesModel.Note        = objNotes[i].UserNote;
                    notesModel.NoteID      = objNotes[i].NoteID;
                    notesModel.UpdatedDate = objNotes[i].UpdatedDate;
                    notesModel.CreatedDate = objNotes[i].CreatedDate;
                    notesModel.UserName    = Session["username"].ToString();

                    if (notesViewModel.NotesList == null)
                    {
                        new List <NotesModel>();
                    }
                    notesViewModel.NotesList.Add(notesModel);
                }
            }

            return(notesViewModel);
        }
Esempio n. 21
0
        /// <summary>
        /// Updates the notes.
        /// </summary>
        /// <param name="notesModel">The notes model.</param>
        /// <param name="UserId"></param>
        /// <returns>return result.</returns>
        /// <exception cref="Exception">throw exception.</exception>
        public async Task <int> UpdateNotes(NotesModel notesModel, int id)
        {
            try
            {
                var updateData = from notes in this.context.Notes
                                 where notes.Id == id
                                 select notes;

                foreach (var update in updateData)
                {
                    update.Title        = notesModel.Title;
                    update.Description  = notesModel.Description;
                    update.Color        = notesModel.Color;
                    update.Image        = notesModel.Image;
                    update.Reminder     = notesModel.Reminder;
                    update.ModifiedDate = notesModel.ModifiedDate;
                    update.noteType     = notesModel.noteType;
                    update.IsPin        = notesModel.IsPin;
                }

                var Result = await this.SaveAll();

                return(Result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 22
0
        public async Task <IActionResult> UpdateNotes(NotesModel notesModel, int id)
        {
            try
            {
                if (!notesModel.Equals(null) && !id.Equals(null))
                {
                    ////BusinessLayer method call
                    var result = await this._businessManager.UpdateNotes(notesModel, id);

                    ////check the result is not null
                    if (!result.Equals(null))
                    {
                        ////return the success result.
                        return(this.Ok(new { result }));
                    }
                    else
                    {
                        ////throw the exception message
                        return(this.BadRequest(new { Message = "The notes are not successfuly updated" }));
                    }
                }
                else
                {
                    ////throw the exception message
                    return(this.BadRequest(new { Message = "The note model or note id is invalid" }));
                }
            }
            catch (Exception ex)
            {
                ////throw the exception message
                throw new Exception(ex.Message);
            }
        }
Esempio n. 23
0
        public NotesInfo DetermineNotesQuantity(int amount)
        {
            try
            {
                var pipe = _pipeFactory.CreatePipe();

                var pipeModel = new NotesModel
                {
                    Amount = amount
                };

                pipe.Execute(pipeModel);

                return(new NotesInfo
                {
                    QuantityOf100Notes = pipeModel.QuantityOf100Notes,
                    QuantityOf50Notes = pipeModel.QuantityOf50Notes,
                    QuantityOf20Notes = pipeModel.QuantityOf20Notes,
                    QuantityOf10Notes = pipeModel.QuantityOf10Notes
                });
            }
            catch (NoteUnavailableException)
            {
                return(new NotesInfo {
                    ErrorMessage = "Note unavailable"
                });
            }
            catch (ArgumentException)
            {
                return(new NotesInfo {
                    ErrorMessage = "Invalid amount"
                });
            }
        }
Esempio n. 24
0
        public bool AddNotes([FromBody] NotesModel notesModel)
        {
            context.Notes.Add(notesModel);
            context.SaveChangesAsync();

            return(true);
        }
        public int AddNotes(NotesModel notesModel)
        {
            var user = new NotesModel()
            {
                userId    = notesModel.userId,
                Title     = notesModel.Title,
                TakeANote = notesModel.TakeANote,
                IsPin     = notesModel.IsPin,
                IsArchive = notesModel.IsArchive,
                IsTrash   = notesModel.IsTrash,
                ColorCode = notesModel.ColorCode,
                ImageUrl  = notesModel.ImageUrl,
                Reminder  = notesModel.Reminder
            };
            int result = 0;

            try
            {
                this.context.Notes.Add(user);
                result = this.context.SaveChanges();
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 26
0
        public async Task <ActionResult> GetAllShopOrders(string shopEmail)
        {
            NotesModel notes = new NotesModel();

            notes.NoteModel = await noteCosmosDBService.GetShopNotesAsList(shopEmail);

            return(Ok(mapper.Map <NotesInfo>(notes).NoteInfo));
        }
Esempio n. 27
0
 public List <Note> GetAllNotes()
 {
     using (var db = new NotesModel())
     {
         var noteList = db.Note.ToList();
         return(noteList);
     }
 }
        public async Task <ActionResult> GetAllUserNotes(string phoneNumber)
        {
            NotesModel notes = new NotesModel();

            notes.NoteModel = await noteCosmosDBService.GetNotes(phoneNumber);

            return(Ok(mapper.Map <NotesInfo>(notes).NoteInfo));
        }
Esempio n. 29
0
 public bool Register(User user)
 {
     using (var db = new NotesModel())
     {
         var result = UserUtil.Register(user.Username, user.Password);
         return(result);
     }
 }
Esempio n. 30
0
        //  public NotesModel Note { get; set; }

        public EditNotePage(NotesModel notesModel)
        {
            InitializeComponent();

            BindingContext = viewModel = new EditNotePageViewModel(notesModel);

            viewModel.Initilize(notesModel);
        }