Ejemplo n.º 1
0
        public ActionResult DeleteSupportMaterial(string id, string fileName)
        {
            using (var tx = new TransactionScope())
            {
                var classRepository = new ClassRepository(_context);
                var klass           = classRepository.GetById(new Guid(id));
                var file            = klass.Files.Single(x => x.PhysicalPath == fileName);
                klass.Files.Remove(file);
                classRepository.UpdateWithFiles(klass);
                _context.Save(_loggedUser);

                var uploader = new SupportMaterialUploader(id);
                uploader.DeleteFile(fileName);

                tx.Complete();
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Ejemplo n.º 2
0
        public ActionResult Delete(string id)
        {
            var classRepository = new ClassRepository(_context);
            var uploader        = new SupportMaterialUploader(id);
            var klass           = classRepository.GetById(new Guid(id));

            using (var tx = new TransactionScope())
            {
                foreach (var file in klass.Files)
                {
                    uploader.DeleteFile(file.PhysicalPath);
                }

                classRepository.Delete(klass.Id);
                _context.Save(_loggedUser);

                tx.Complete();
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }