Esempio n. 1
0
 public async Task <ActionResponse <TeacherFileDto> > RemoveFile(TeacherFileDto entity)
 {
     try
     {
         unitOfWork.GetGenericRepository <TeacherFile>().Delete(entity.Id.Value);
         unitOfWork.Save();
         return(await ActionResponse <TeacherFileDto> .ReturnSuccess(null, "Dokument uspješno maknut s nastavnika."));
     }
     catch (Exception)
     {
         return(await ActionResponse <TeacherFileDto> .ReturnError("Greška prilikom micanja dokumenta s nastavnika."));
     }
 }
Esempio n. 2
0
 public async Task <ActionResponse <TeacherFileDto> > AddFile(TeacherFileDto file)
 {
     try
     {
         var entityToAdd = mapper.Map <TeacherFileDto, TeacherFile>(file);
         unitOfWork.GetGenericRepository <TeacherFile>().Add(entityToAdd);
         unitOfWork.Save();
         return(await ActionResponse <TeacherFileDto>
                .ReturnSuccess(mapper.Map <TeacherFile, TeacherFileDto>(entityToAdd), "Dokument uspješno dodan nastavniku."));
     }
     catch (Exception)
     {
         return(await ActionResponse <TeacherFileDto> .ReturnError("Greška prilikom dodavanja dokumenta nastavniku."));
     }
 }