public async Task <IActionResult> Edit(int classid, ClassForCrudDto classForCrudDto) { var classe = await _repo.GetClass(classid); _mapper.Map(classForCrudDto, classe); if (await _repo.Save()) { return(Ok("Class Modified successfully !")); } throw new Exception("ERROR, Problem occured while modifying the class"); }
public async Task <IActionResult> AjouterClasse(ClassForCrudDto classForCrudDto) { var classe = _mapper.Map <Class>(classForCrudDto); classe.Owner = _userManager.GetUserAsync(HttpContext.User).Result; _repo.Add(classe); var classmember = new ClassAppUser { Class = classe, Member = classe.Owner, verified = true }; _repo.Add(classmember); if (await _repo.Save()) { return(Ok("Class added successfully !")); } throw new Exception("ERROR, Problem occured while adding you to the class members"); }