Ejemplo n.º 1
0
        /// <summary>
        /// 수정
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> EditAsync(NoteRequest model)
        {
            try
            {
                NoteModel note = new NoteModel()
                {
                    Id        = model.Id,
                    Name      = model.Name,
                    Title     = model.Title,
                    Content   = model.Content,
                    FilePath  = model.FilePath,
                    CreatedBy = model.CreatedBy,
                    Modified  = DateTime.Now
                };

                _context.Notes.Attach(note);
                _context.Entry(note).State = EntityState.Modified;


                return(await _context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (Exception e)
            {
                _logger.LogError($"ERROR({nameof(EditAsync)}): {e.Message}");
            }

            return(false);
        }
Ejemplo n.º 2
0
 public object Put(NoteRequest request)
 {
     var note = OrmLiteDbFactory.Get<NoteResourceModel>(request.NoteId);
     note.Text = request.Text;
     OrmLiteDbFactory.InsertOrUpdate(note);
     return new NoteResponse { Result = "Updated Note: " + note.Id + " with text: " + note.Text };
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreateNote(NoteRequest noteRequest)
        {
            try
            {
                var userId = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;

                var data = await this.noteBL.CreateNote(noteRequest, userId);

                bool success = false;
                var  message = string.Empty;

                // check whether result is true or false
                if (data != null)
                {
                    // if true then return the result
                    success = true;
                    message = "Succeffully Created Note";
                    return(this.Ok(new { success, message, data }));
                }
                else
                {
                    success = false;
                    message = "Failed";
                    return(this.BadRequest(new { success, message }));
                }
            }
            catch (Exception exception)
            {
                return(this.BadRequest(new { exception.Message }));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Remove all notes
        /// </summary>
        private async void ClearAllNotes()
        {
            ServiceManager noteGetServiceManager =
                new ServiceManager(new Uri(note_base_uri));

            var notes = await noteGetServiceManager.CallService <Note[]>();

            int numDeleted = 0;

            foreach (var note in notes)
            {
                NoteRequest noteReq = new NoteRequest()
                {
                    Id = note.Id, NoteText = note.NoteText
                };
                ServiceManager noteServiceManager = new ServiceManager(new Uri(note_base_uri + "/" + noteReq.Id));

                if (await noteServiceManager.CallDeleteService <NoteRequest>(noteReq))
                {
                    numDeleted++;
                }
            }
            ;
            ShowPopupMessage(string.Format("Deleted {0} notes from the DB!", numDeleted));

            UpdateCurrentNoteDisplay();
        }
Ejemplo n.º 5
0
        public void CreateNewNoteForCompanyTest()
        {
            NoteRequest request = new NoteRequest(m_highriseURL, m_highriseAuthToken);
            string      result  = request.CreateNoteForCompany(57644826, "Hello World (" + DateTime.UtcNow.ToString("dd MMM yyyy HH:mm:ss") + ").");

            Assert.IsNotNull(result, "The result of the create note request should not have been null.");
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PostEmployeeNoteAsync([FromBody] NoteRequest request)
        {
            var entity = request;

            entity.EntityTypeId = (int)EntityTypeEnum.Employee;
            entity.EntityId     = request.EmployeeId;
            var response = await EmployeeService.CreateEmployeeNoteAsync(entity);



            Docs docs = new Docs();

            docs.EntityId     = response.Model.NoteId;
            docs.EntityTypeId = (int)EntityTypeEnum.Note;

            var DOCSResponse = await EmployeeService.CreateDocsAsync(docs, typeof(Notes), request.NoteContent, request.FileRequest, (int)DocumentType.Note);

            if (DOCSResponse.DIdError)
            {
                throw new Exception("Error in create Document Notes" + response.Message);
            }


            SingleResponse <NoteRequest> res = new SingleResponse <NoteRequest>();

            res.Model = response.Model.ToEntity(null, request.EmployeeId, DOCSResponse.Model);

            return(res.ToHttpResponse());
        }
Ejemplo n.º 7
0
        public string Delete()
        {
            CSC425Context db       = new CSC425Context();
            var           apikey   = Request.Query["api_key"].ToString();
            var           NoteID   = Int32.Parse(Request.Query["noteid"].ToString());
            var           Username = Request.Query["username"].ToString();
            var           note     = db.Notes.Where(n => n.NotesId.Equals(NoteID)).FirstOrDefault();
            var           user     = db.Users.Where(u => u.Username.ToLower().Equals(Username.ToLower())).FirstOrDefault();

            if (note == null)
            {
                return(JsonConvert.SerializeObject(new ReturnCode(404, "Not Found", "That note doesn't exist.")));
            }

            if (!note.UserId.Equals(user.UserId))
            {
                return(JsonConvert.SerializeObject(new ReturnCode(403, "Forbidden", "That note doesn't belong to you.")));
            }

            var req = new NoteRequest(db, note, user);

            if (apikey.ToLower() != Security.APIKey)
            {
                return(JsonConvert.SerializeObject(new ReturnCode(401, "Unauthorized", "Bad API Key")));
            }

            return(req.DeleteNote(db));
        }
Ejemplo n.º 8
0
        public async Task <AOResult> UpdateNoteAsync(NoteRequest noteRequest)
        {
            return(await BaseInvokeAsync(async() =>
            {
                Note note = await _myHelperDbContext.Notes.FirstOrDefaultAsync(x => x.Id == noteRequest.Id);

                if (note == null)
                {
                    return AOBuilder.SetError(Constants.Errors.NoteNotExists);
                }

                note.Name = noteRequest.Name;
                note.Description = noteRequest.Description;
                note.UpdateDate = DateTime.Now;

                _myHelperDbContext.Notes.Update(note);

                var noteTags = await _myHelperDbContext.NoteTags.Where(x => x.NoteId == note.Id).ToListAsync();
                _myHelperDbContext.NoteTags.RemoveRange(noteTags.Where(x => !noteRequest.TagIds.Contains(x.TagId)));

                await _myHelperDbContext.NoteTags.AddRangeAsync(
                    noteRequest.TagIds
                    .Join(_myHelperDbContext.Tags, o => o, i => i.Id, (o, i) => i)
                    .Where(x => !noteTags.Select(y => y.TagId).Contains(x.Id))
                    .Select(x => new NoteTag {
                    Tag = x, Note = note
                }));

                await _myHelperDbContext.SaveChangesAsync();

                return AOBuilder.SetSuccess();
            }, noteRequest));
        }
Ejemplo n.º 9
0
        public CreateNoteResponse Create([FromBody] NoteRequest note)
        {
            var newNote   = new Note(note.Title, note.Contents);
            var newNoteId = _notesRepository.Create(newNote);

            return(new CreateNoteResponse(newNoteId));
        }
Ejemplo n.º 10
0
        ////Put: /api/Note/UpdateNote
        public async Task <IActionResult> UpdateNote(NoteRequest noteRequest, int noteID)
        {
            try
            {
                var userID = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;

                var result = await this.noteBL.UpdateNote(noteRequest, noteID, userID);

                bool success = false;
                var  message = string.Empty;
                if (result != null)
                {
                    success = true;
                    message = "Updated Successfully";
                    return(this.Ok(new { success, message, result }));
                }
                else
                {
                    success = false;
                    message = "Failed";
                    return(this.BadRequest(new { success, message }));
                }
            }
            catch (Exception exception)
            {
                return(this.BadRequest(exception.Message));
            }
        }
Ejemplo n.º 11
0
        public async Task <AOResult <long> > CreateNoteAsync(NoteRequest noteRequest)
        {
            return(await BaseInvokeAsync(async() =>
            {
                var note = new Note
                {
                    Name = noteRequest.Name,
                    Description = noteRequest.Description,
                    UpdateDate = DateTime.Now,
                    AppUserId = noteRequest.AppUserId
                };

                await _myHelperDbContext.Notes.AddAsync(note);

                if (noteRequest.TagIds.Any())
                {
                    var noteTags = noteRequest.TagIds
                                   .Join(_myHelperDbContext.Tags, o => o, i => i.Id, (o, i) => i)
                                   .Select(x => new NoteTag
                    {
                        Note = note,
                        Tag = x
                    });

                    await _myHelperDbContext.NoteTags.AddRangeAsync(noteTags);
                }

                await _myHelperDbContext.SaveChangesAsync();

                return AOBuilder.SetSuccess(note.Id);
            }, noteRequest));
        }
Ejemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="noteText"></param>
        private async void WriteNote(string noteText)
        {
            NoteRequest noteReq = new NoteRequest()
            {
                Id       = 2,
                NoteText = noteText
            };//"{\"Id\": 3,\"NoteText\": \"" + noteText + "\"}";

            ServiceManager noteManager    = new ServiceManager(new Uri(note_base_uri));
            bool           successfulCall = await noteManager.CallPOSTService <NoteRequest>(noteReq);

            if (successfulCall)
            {
                ShowPopupMessage(string.Format("Note successfully updated!\rSet to: {0}", noteText), "Note Update");
            }
            else
            {
                ShowPopupMessage("Note was not able to be updated at this time.", "Note Update");
            }

            UpdateCurrentNoteDisplay();
            NewNoteTextBox.Text = "";

            //Remind the user to set a note every day! <3
            NotificationManager.ScheduleNotification("Don't forget to update your daily Note!", DateTime.Now.AddDays(1), NotificationType.Toast);
            //TODO: Pull schedule info from config
        }
        public void CreateNewNoteForPersonTest()
        {
            NoteRequest request = new NoteRequest(m_highriseURL, m_highriseAuthToken);
            string result = request.CreateNoteForPerson(59708303, "Hello World (" + DateTime.UtcNow.ToString("dd MMM yyyy HH:mm:ss") + ").");

            Assert.IsNotNull(result, "The result of the create note request should not have been null.");
        }
Ejemplo n.º 14
0
        public int SaveNote(NoteRequest request)
        {
            var nitem = new DataAccess.SirCoPOS.Nota
            {
                Date       = DateTime.Now,
                Sucursal   = request.Sucursal,
                CajeroId   = 0,
                VendedorId = request.VendedorId
            };

            _ctx.Notas.Add(nitem);
            nitem.Items = new HashSet <DataAccess.SirCoPOS.NotaDetalle>();
            nitem.Pagos = new HashSet <DataAccess.SirCoPOS.NotaPago>();
            foreach (var item in request.Items)
            {
                nitem.Items.Add(new DataAccess.SirCoPOS.NotaDetalle
                {
                    Serie   = item.Serie,
                    Amount  = item.Amount,
                    Coments = item.Comments
                });
            }
            _ctx.SaveChanges();

            return(nitem.Id);
        }
Ejemplo n.º 15
0
        public async Task <ServerResponse <long> > CreateNoteAsync(NoteRequest noteRequest)
        {
            return(await BaseInvokeAsync(async() =>
            {
                var note = new Note
                {
                    Name = noteRequest.Name,
                    Description = noteRequest.Description,
                    VisibleType = noteRequest.VisibleType,
                    UpdateDate = DateTime.Now,
                    AppUserId = noteRequest.AppUserId
                };

                await DbContext.Notes.AddAsync(note);

                if (noteRequest.TagIds.Any())
                {
                    var noteTags = noteRequest.TagIds
                                   .Join(DbContext.Tags, o => o, i => i.Id, (o, i) => i)
                                   .Select(x => new NoteTag
                    {
                        Note = note,
                        Tag = x
                    });

                    await DbContext.NoteTags.AddRangeAsync(noteTags);
                }

                await DbContext.SaveChangesAsync();

                return ServerResponseBuilder.Build(note.Id);
            }, noteRequest));
        }
Ejemplo n.º 16
0
        public ActionResult Index(NoteRequest request)
        {
            var notes = NotesDAL.Retrieve(request);

            ViewBag.Title = "Notes";

            return(View(notes));
        }
Ejemplo n.º 17
0
        public async Task <ServerResponse <bool> > UpdateNoteAsync([FromBody] NoteRequest noteRequest)
        {
            var serverResponse = await _noteService.UpdateNoteAsync(noteRequest);

            await _sendEndpointProvider.Send(_noteService.CreateFeedMessage(noteRequest, EFeedAction.Update));

            return(serverResponse);
        }
Ejemplo n.º 18
0
        public async Task <ServerResponse <long> > CreateNoteAsync([FromBody] NoteRequest noteRequest)
        {
            var serverResponse = await _noteService.CreateNoteAsync(noteRequest);

            noteRequest.Id = serverResponse.Result;
            await _sendEndpointProvider.Send(_noteService.CreateFeedMessage(noteRequest, EFeedAction.Create));

            return(serverResponse);
        }
Ejemplo n.º 19
0
        private void ValidateNote(NoteRequest model)
        {
            var validationResult = _noteModelValidator.Validate(model);

            if (!validationResult.IsValid)
            {
                throw new ValidationException(validationResult.Errors);
            }
        }
Ejemplo n.º 20
0
        public async Task <ServerResponse <long> > CreateNoteAsync([FromBody] NoteRequest noteRequest)
        {
            return(AOResultToServerResponse(await _noteService.CreateNoteAsync(noteRequest).ContinueWith(x =>
            {
                var request = _requestClient.Create(_noteService.CreateNoteFeedMessage(noteRequest, x.Result.Result));

                request.GetResponse <FeedMessage>();

                return x.Result;
            })));
        }
Ejemplo n.º 21
0
        public async Task <NoteResponse> UpdateNoteAsync(NoteRequest noteRequest)
        {
            _logger.LogInformation("Updating a note with id '{noteId}' to '{@noteRequest}'", noteRequest.Key, noteRequest);

            var simpleNote  = noteRequest.Adapt <SimpleNote>();
            var changedNote = await _repositoryWrapper.Notes.UpdateAsync(simpleNote);

            await _repositoryWrapper.SaveAsync();

            return(changedNote.Adapt <NoteResponse>());
        }
Ejemplo n.º 22
0
        public async Task <bool> UpdateNote(NoteRequest note)
        {
            var content     = JsonSerializer.Serialize(note);
            var bodyContent = new StringContent(content, Encoding.UTF8, "application/json");

            var result = await _client.PutAsync("/api/notes", bodyContent);



            return(result.IsSuccessStatusCode);
        }
Ejemplo n.º 23
0
 public object Get(NoteRequest request)
 {
     if (request.NoteId == Guid.Empty)
     {
         var allNotes = OrmLiteDbFactory.GetAll<NoteResourceModel>();
         ////Consider making full use of ormlite and think of remaking repository
         return new NoteResponse { Result = "All Notes Returned: " + allNotes.SerializeToString() };
     }
     var note = OrmLiteDbFactory.Get<NoteResourceModel>(request.NoteId);
     return new NoteResponse { Result = "Note is: " + note.Id + "  Text is: " + note.Text };
 }
Ejemplo n.º 24
0
        public async Task <IActionResult> CreateNote([FromBody] NoteRequest note)
        {
            if (note == null)
            {
                return(BadRequest());
            }

            await _repository.AddAsync(note);

            return(CreatedAtAction("GetNoteById", new { id = note.Id }, note));
        }
Ejemplo n.º 25
0
        public string Put([FromBody] NoteRequest note)
        {
            CSC425Context db     = new CSC425Context();
            var           apikey = Request.Query["api_key"].ToString();

            if (apikey.ToLower() != Security.APIKey)
            {
                return(JsonConvert.SerializeObject(new ReturnCode(401, "Unauthorized", "Bad API Key")));
            }

            return(note.UpdateNote(db));
        }
Ejemplo n.º 26
0
        private async Task <NoteResponse> CreateNoteAsync(NoteRequest request)
        {
            var jsonString = JsonSerializer.Serialize(request);
            var content    = new StringContent(jsonString, Encoding.UTF8, "application/json");

            var response = await _applicationAuthorizedClient.Client.PostAsync("/api/notes", content);

            var responseJson = await response.Content.ReadAsStringAsync();

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            return(JsonSerializer.Deserialize <NoteResponse>(responseJson));
        }
Ejemplo n.º 27
0
        public async Task CreateNote(NoteRequest noteRequest)
        {
            var note = new FWTCreateNoteToParent
            {
                NoteDetails = new FWTCreateNoteDetail
                {
                    Text = noteRequest.NoteText
                },
                ParentId   = noteRequest.CaseRef,
                ParentType = noteRequest.Interaction
            };

            await _verintConnection.createNotesAsync(note);
        }
Ejemplo n.º 28
0
        public static List <Note> Retrieve(NoteRequest request)
        {
            List <Note> list = new List <Note>();

            using (MemoTestContext ctx = new MemoTestContext(GetConnectionString()))
            {
                list.AddRange((from note in ctx.Notes
                               where
                               (string.IsNullOrEmpty(request.Name) || note.Name == request.Name)
                               orderby note.IsMarked descending, note.CreationDate descending
                               select note).ToList());
            }
            return(list);
        }
Ejemplo n.º 29
0
        public async Task Post_ShouldCreateNote()
        {
            var request = new NoteRequest
            {
                Name    = "Example of note",
                Content = "Example of content"
            };

            var note = await CreateNoteAsync(request);

            Assert.Equal(request.Name, note.Name);
            Assert.Equal(request.Content, note.Content);
            Assert.True(note.Key != 0);
        }
Ejemplo n.º 30
0
        public NoteResponse Create(NoteRequest model, AccessTokenData accessTokenData)
        {
            ValidateNote(model);

            var addedNote = _notesRepository.Create(new NoteEntity()
            {
                Name        = model.Name,
                CreatedTime = DateTime.Now,
                UpdateTime  = DateTime.Now,
                Text        = model.Text,
                UserKey     = accessTokenData.UserKey
            });

            return(ToNoteResponse(addedNote));
        }
Ejemplo n.º 31
0
        public IActionResult Edit(int id, [FromBody] NoteRequest note)
        {
            var updatedNote = new Note(id, note.Title, note.Contents);

            try
            {
                _notesRepository.Edit(updatedNote);
            }
            catch (ResourceNotFoundException)
            {
                return(NotFound(new ErrorResponse("Could not find note with ID " + id.ToString())));
            }

            return(Ok());
        }
Ejemplo n.º 32
0
        public async Task Create(NoteRequest note)
        {
            var content     = JsonSerializer.Serialize(note);
            var bodyContent = new StringContent(content, Encoding.UTF8, "application/json");

            var postResult = await _client.PostAsync("/api/notes", bodyContent);


            var postContent = await postResult.Content.ReadAsStringAsync();

            if (!postResult.IsSuccessStatusCode)
            {
                throw new ApplicationException(postContent);
            }
        }
Ejemplo n.º 33
0
        public async Task <NoteResponse> CreateNoteAsync(NoteRequest noteRequest)
        {
            _logger.LogInformation("Creating a note {@noteRequest}...", noteRequest);

            var simpleNote = noteRequest.Adapt <SimpleNote>();

            simpleNote.Key     = 0;
            simpleNote.Created = simpleNote.Changed = DateTimeOffset.Now.ToUnixTimeSeconds();
            simpleNote.UserId  = _userAccessor.CurrentUserId;

            var createdNote = await _repositoryWrapper.Notes.InsertAsync(simpleNote);

            await _repositoryWrapper.SaveAsync();

            return(createdNote.Adapt <NoteResponse>());
        }
Ejemplo n.º 34
0
 public object Delete(NoteRequest request)
 {
     OrmLiteDbFactory.Delete<NoteResourceModel>(request.NoteId);
     return new NoteResponse { Result = "Deleted: " + request.NoteId };
 }
Ejemplo n.º 35
0
 public object Post(NoteRequest request)
 {
     OrmLiteDbFactory.Put(new NoteResourceModel { Id = Guid.NewGuid(), Text = request.Text });
     return new NoteResponse { Result = "Added: " + request.NoteId + " Text: " + request.Text };
 }
Ejemplo n.º 36
0
        private void AddHighriseCallNote(string url, string authToken, SIPFromHeader caller, Person person)
        {
            try
            {
                NoteRequest request = new NoteRequest(url, authToken);
                string result = request.CreateNoteForPerson(person.ID, HttpUtility.HtmlEncode("Incoming SIP call as " + caller.FromUserField.ToParameterlessString() + " at " + DateTime.UtcNow.ToString("dd MMM yyyy HH:mm:ss") + " UTC."));
                string personName = person.FirstName + " " + person.LastName;

                if(result != null)
                {
                    LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Highrise call received note added for " + personName + ".", m_context.Owner));
                }
                else
                {
                    LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Failed to add Highrise call received note for " + personName + ".", m_context.Owner));
                }
            }
            catch (Exception excp)
            {
                LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Exception attempting to add Highrise call received note. " + excp.Message, m_context.Owner));
            }
        }
        private void AddHighriseCallNote(string url, string authToken, Person person)
        {
            try
            {
                NoteRequest request = new NoteRequest(url, authToken);
                string result = request.CreateNoteForPerson(person.ID, "Called at " + DateTime.UtcNow.ToString("dd MMM yyyy HH:mm:ss") + " UTC.");
                string personName = person.FirstName + " " + person.LastName;

                if(result != null)
                {
                    LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Highrise call received note added for " + personName + ".", m_context.Owner));
                }
                else
                {
                    LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Failed to add Highrise call received note for " + personName + ".", m_context.Owner));
                }
            }
            catch (Exception excp)
            {
                LogToMonitor(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Exception attempting to add Highrise call received note.", m_context.Owner));
            }
        }