public async Task UpdateSection(Guid id, SectionRegister entity) { var captureModel = await _context.ClamSectionAcademicSubCategories.FindAsync(entity.SubCategoryId); _context.Entry(captureModel).Entity.SubCategoryTitle = entity.SubCategoryTitle; _context.Entry(captureModel).Entity.SubCategoryDescription = entity.SubCategoryDescription; _context.Entry(captureModel).Entity.LastModified = DateTime.Now; _context.Entry(captureModel).State = EntityState.Modified; _context.Update(captureModel); await _context.SaveChangesAsync(); }
public void AddSection(Guid id, SectionRegister entity) { ClamSectionAcademicSubCategory model = new ClamSectionAcademicSubCategory { SubCategoryTitle = entity.SubCategoryTitle, SubCategoryDescription = entity.SubCategoryDescription, AcademicId = id }; _context.ClamSectionAcademicSubCategories.Add(model); Task.WaitAll(_context.SaveChangesAsync()); }
public async Task <IActionResult> CreateSection(Guid id, string category, SectionRegister entity) { try { await _unitOfWork.AcademiaControl.AddAsyncSection(id, entity); _unitOfWork.Complete(); return(RedirectToAction(nameof(Section), new { Id = id, Category = category })); } catch (Exception) { throw; } }
public async Task RemoveSection(Guid id, SectionRegister entity) { var model = await _context.ClamSectionAcademicSubCategories.FindAsync(entity.SubCategoryId); var keyDirPhysicalPath = Path.Combine(model.AcademicId.ToString(), entity.SubCategoryId.ToString()); var subDirPhysicalPath = Path.Combine(_targetFolderPath, keyDirPhysicalPath); if (Directory.Exists(subDirPhysicalPath)) { Directory.Delete(subDirPhysicalPath, true); } _context.ClamSectionAcademicSubCategories.Remove(model); await _context.SaveChangesAsync(); }
public async Task <IActionResult> DeleteSection(Guid id, SectionRegister entity, string category, string section) { try { var model = await _unitOfWork.AcademiaControl.GetSelectedSection(entity.SubCategoryId); await _unitOfWork.AcademiaControl.RemoveSection(id, entity); _unitOfWork.Complete(); return(RedirectToAction(nameof(Section), new { Id = model.AcademicId, Category = category })); } catch (Exception) { return(View()); } }