예제 #1
0
        public async Task <NotesDto> AddTags(NotesDto notesDto)
        {
            var tags = await _context.Tags.Where(x => x.NoteId == notesDto.Id).Select(x => x.Tag).ToListAsync();

            notesDto.Tags = tags;
            return(notesDto);
        }
예제 #2
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());
        }
예제 #3
0
        public async Task <NotesDto> CreateNote([FromForm] NotesDto notesDto)
        {
            var note = _mapper.Map <NotesDto, Notes>(notesDto);

            _unitOfWork.NotesRepository.Add(note);
            await _unitOfWork.CompleteAsync();

            var result = _mapper.Map <Notes, NotesDto>(note);

            return(result);
        }
예제 #4
0
        public NotesDto UpdateNote(NotesDto objNotesDto)
        {
            Notes objNotes     = _mapper.Map <Notes>(objNotesDto);
            Notes objNotesData = _context.Notes.Find(objNotesDto.NotesId);

            objNotes.ModifiedDateTime = DateTime.Now;
            objNotes.ModifiedBy       = 1;
            _context.Entry(objNotesData).CurrentValues.SetValues(objNotes);
            _context.SaveChanges();
            return(_mapper.Map <NotesDto>(_context.Notes.
                                          SingleOrDefault(x => x.NotesId == objNotesDto.NotesId)));
        }
예제 #5
0
        public NotesDto CreateNote(NotesDto objNotesDto)
        {
            Notes objNotes = _mapper.Map <Notes>(objNotesDto);

            objNotes.CreatedDateTime = DateTime.Now;
            objNotes.CreatedBy       = 1;
            _context.Notes.Add(objNotes);
            _context.SaveChanges();

            return(_mapper.Map <NotesDto>(_context.Notes.
                                          SingleOrDefault(x => x.NotesId == objNotesDto.NotesId)));
        }
예제 #6
0
        public IActionResult Put([FromBody] NotesDto notesDto)
        {
            try
            {
                _notesRepository.Update(notesDto.id, notesDto.notes);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
예제 #7
0
        public static NotesDto ToDto(this Note note, string email)
        {
            var noteDto = new NotesDto
            {
                Id      = note.Id,
                Title   = note.Title,
                Date    = note.Date,
                Content = note.Content,
                Email   = email,
                Link    = note.Link
            };

            return(noteDto);
        }
예제 #8
0
 public NotesDto EditNotes(NotesDto notesDto)
 {
     try
     {
         if (notesDto == null)
         {
             return(null);
         }
         Notes notes = this.NotesMapper.DtoToModel(notesDto);
         notes = this.NotesRepository.Update(notes);
         return(this.NotesMapper.ModelToDto(notes));
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
예제 #9
0
 public NotesDto AddNewNotes(NotesDto notesDto, Guid caseId)
 {
     try
     {
         if (notesDto == null)
         {
             return(null);
         }
         Notes notes = NotesMapper.DtoToModel(notesDto);
         notes.CaseId = caseId;
         notes        = this.NotesRepository.Add(notes);
         return(this.NotesMapper.ModelToDto(notes));
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
예제 #10
0
        public IActionResult Post([FromBody] NotesDto notesDto)
        {
            try
            {
                var note = new NotesModel()
                {
                    notes        = notesDto.notes,
                    favorited_id = notesDto.favorited_id,
                    user_id      = notesDto.user_id
                };
                _notesRepository.Insert(note);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
예제 #11
0
 public NotesDto Update([FromBody] NotesDto model)
 {
     return(_notesService.UpdateNote(model));
 }
예제 #12
0
        public OperationResponse <CaseDto> Put(EditCase request)
        {
            OperationResponse <CaseDto> operationResponse = new OperationResponse <CaseDto>();

            ClientValidator          clientValidator          = new ClientValidator();
            CaseInformationValidator caseInformationValidator = new CaseInformationValidator();
            NotesValidator           notesValidator           = new NotesValidator();

            CaseInformationDto      caseInformation = request.CaseDto.CaseInformation;
            ClientDto               client          = request.CaseDto.Client;
            NotesDto                notes           = request.CaseDto.Notes;
            CaseStatusDto           caseStatus      = request.CaseDto.CaseStatus;
            List <CaseReferenceDto> references      = request.CaseDto.References;

            ValidationResult validationResult = clientValidator.Validate(client);

            if (!validationResult.IsValid)
            {
                List <string> errors = new List <string>();
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
                operationResponse.OnError("Invalid client data", errors);
                return(operationResponse);
            }

            validationResult = caseInformationValidator.Validate(caseInformation);
            if (!validationResult.IsValid)
            {
                List <string> errors = new List <string>();
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
                operationResponse.OnError("Invalid case-information data", errors);
                return(operationResponse);
            }

            validationResult = notesValidator.Validate(notes);
            if (!validationResult.IsValid)
            {
                List <string> errors = new List <string>();
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
                operationResponse.OnError("Invalid case-information data", errors);
                return(operationResponse);
            }

            try
            {
                CaseDto caseDto = this.CaseBusinessLogic.EditCase(client.CaseId, client, caseInformation, notes, caseStatus, references);
                operationResponse.OnSuccess(caseDto, "Saved successfully");
                return(operationResponse);
            }
            catch (Exception e)
            {
                Log.Error(e.Message + " " + e.StackTrace);
                operationResponse.OnException(e.Message);
                return(operationResponse);
            }
        }
 public async Task <IActionResult> CreateFolders([FromBody] NotesDto notesDto) => Ok(await _notesService.CreateNote(notesDto));
예제 #14
0
        public OperationResponse <CaseDto> Post(CreateCase request)
        {
            OperationResponse <CaseDto> operationResponse = new OperationResponse <CaseDto>();

            ClientValidator          clientValidator          = new ClientValidator();
            CaseInformationValidator caseInformationValidator = new CaseInformationValidator();
            NotesValidator           notesValidator           = new NotesValidator();

            CaseInformationDto      caseInformation = request.CaseDto.CaseInformation;
            ClientDto               client          = request.CaseDto.Client;
            NotesDto                notes           = request.CaseDto.Notes;
            CaseStatusDto           caseStatus      = request.CaseDto.CaseStatus;
            List <CaseReferenceDto> references      = request.CaseDto.References;
            List <string>           errors          = new List <string>();

            ValidationResult validationResult = clientValidator.Validate(client);

            if (!validationResult.IsValid)
            {
                ;
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
            }

            validationResult = caseInformationValidator.Validate(caseInformation);
            if (!validationResult.IsValid)
            {
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
            }

            validationResult = notesValidator.Validate(notes);
            if (!validationResult.IsValid)
            {
                foreach (var error in validationResult.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }
            }

            if (errors.Count != 0)
            {
                operationResponse.OnError("Invalid input data", errors);
                return(operationResponse);
            }

            try
            {
                CaseDto caseDto = CaseBusinessLogic.AddNewCase(client, caseInformation, notes, caseStatus, references);
                operationResponse.OnSuccess(caseDto, "Added successfully");
                return(operationResponse);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                operationResponse.OnException(e.Message);
                return(operationResponse);
            }
        }
예제 #15
0
        public CaseDto EditCase(Guid caseId, ClientDto clientDto, CaseInformationDto caseInformationDto, NotesDto notesDto, CaseStatusDto caseStatusDto, List <CaseReferenceDto> caseReferenceDtos)
        {
            CaseDto caseDto = new CaseDto();

            try
            {
                var caseList = this.CaseRepository.Find(c => c.Id == caseId);
                if (caseList.Count == 0)
                {
                    return(null);
                }

                Case @case = caseList.First();
                @case              = this.CaseRepository.Update(@case);
                caseDto.Id         = @case.Id;
                caseDto.CaseId     = @case.CaseId;
                caseDto.ModifiedOn = @case.ModifiedOn;
                caseDto.CreatedOn  = @case.CreatedOn;

                caseDto.Client          = this.ClientBusinessLogic.EditClient(clientDto);
                caseDto.CaseInformation = this.CaseInformationBusinessLogic.EditCaseInformation(caseInformationDto);
                caseDto.CaseStatus      = this.CaseStatusBusinessLogic.EditCaseStatus(caseStatusDto);
                caseDto.Notes           = this.NotesBusinessLogic.EditNotes(notesDto);
                caseDto.References      = this.CaseReferenceBusinessLogic.EditCaseReferences(caseReferenceDtos, caseId);
                return(caseDto);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
예제 #16
0
 public CaseDto AddNewCase(ClientDto clientDto, CaseInformationDto caseInformationDto, NotesDto notesDto, CaseStatusDto caseStatusDto, List <CaseReferenceDto> caseReferenceDtos)
 {
     try
     {
         CaseDto addedCaseDto = new CaseDto();
         Case    newCase      = new Case();
         Case    addedCase    = CaseRepository.Add(newCase);
         addedCaseDto.CaseId          = addedCase.CaseId;
         addedCaseDto.Id              = addedCase.Id;
         addedCaseDto.ModifiedOn      = addedCase.ModifiedOn;
         addedCaseDto.CreatedOn       = addedCase.CreatedOn;
         addedCaseDto.Client          = ClientBusinessLogic.AddNewClient(clientDto, addedCase.Id);
         addedCaseDto.CaseInformation = CaseInformationBusinessLogic.AddNewCaseInformation(caseInformationDto, addedCase.Id);
         addedCaseDto.CaseStatus      = CaseStatusBusinessLogic.AddNewCaseStatus(caseStatusDto, addedCase.Id);
         addedCaseDto.Notes           = NotesBusinessLogic.AddNewNotes(notesDto, addedCase.Id);
         addedCaseDto.References      = CaseReferenceBusinessLogic.AddNewCaseReferences(caseReferenceDtos, addedCase.Id);
         return(addedCaseDto);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
예제 #17
0
 public NotesDto SaveNote([FromBody] NotesDto model)
 {
     return(_notesService.CreateNote(model));
 }