public async Task UpDatePmsFileAsync(string id, PmsFile updatedPmsFile)
        {
            if (updatedPmsFile == null)
            {
                throw new ArgumentNullException(nameof(updatedPmsFile));
            }

            await dbContext.PmsFiles.ReplaceOneAsync(file => file.PmsFileID == id, updatedPmsFile);
        }
        public async Task CreatePmsFileAsync(PmsFile newPmsFile)
        {
            if (newPmsFile == null)
            {
                throw new ArgumentNullException(nameof(newPmsFile));
            }

            await dbContext.PmsFiles.InsertOneAsync(newPmsFile);
        }
Example #3
0
        public async Task <ActionResult> UpDatePmsFileAsync(string id, PmsFile updatedPmsFile)
        {
            var original = pmsFileRepository.GetPmsFileByIdAsync(id);

            if (original == null)
            {
                return(NotFound($"Could not find PmsFile with id = {id}"));
            }

            await pmsFileRepository.UpDatePmsFileAsync(id, updatedPmsFile);

            return(NoContent());
        }
Example #4
0
        public async Task <ActionResult> CreatePmsFileAsync(PmsFile newPmsFile)
        {
            var alreadyExistingFile = pmsFileRepository.GetPmsFileByStudentIdAsync(newPmsFile.StudentID);

            if (alreadyExistingFile != null)
            {
                return(BadRequest($"A PmsFile from the student with id = {newPmsFile.StudentID} already exists in the Database"));
            }

            await pmsFileRepository.CreatePmsFileAsync(newPmsFile);

            return(CreatedAtRoute(nameof(GetPmsFileByStudentIdAsync), new { studentId = newPmsFile.StudentID }, newPmsFile));
        }