public async Task <IActionResult> PutEndingCoursePoint(int id, EndingCoursePointViewModel endingCoursePoint) { if (endingCoursePoint.Id != id) { throw new Exception(string.Format("Id và Id của giáo viên không giống nhau!")); } try { await Task.Run(() => { _endingCoursePointService.Update(endingCoursePoint); _endingCoursePointService.SaveChanges(); return(Ok("Cập nhập thành công!")); }); } catch (DbUpdateConcurrencyException) { if (!EndingCoursePointExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public bool Update(EndingCoursePointViewModel endingCoursePointVm) { try { var endingCoursePoint = Mapper.Map <EndingCoursePointViewModel, EndingCoursePoint>(endingCoursePointVm); endingCoursePoint.DateModified = DateTime.Now; _endingCoursePointRepository.Update(endingCoursePoint); return(true); } catch { return(false); } }
public bool Add(EndingCoursePointViewModel endingCoursePointVm) { try { var endingCoursePoint = Mapper.Map <EndingCoursePointViewModel, EndingCoursePoint>(endingCoursePointVm); _endingCoursePointRepository.Add(endingCoursePoint); LogSystem logSystem = new LogSystem(); logSystem.EndingCoursePointId = endingCoursePoint.Id; logSystem.UserId = endingCoursePoint.AppUserId; logSystem.LecturerId = endingCoursePoint.LecturerId; logSystem.Content = "Tạo bảng điểm cuối khóa lớp " + _languageclassRepository.FindById(endingCoursePoint.LanguageClassId).Name; logSystem.DateCreated = DateTime.Now; logSystem.DateModified = DateTime.Now; logSystem.IsManagerPointLog = true; _context.LogSystems.Add(logSystem); return(true); } catch { return(false); } }
public async Task <ActionResult <EndingCoursePointViewModel> > PostEndingCoursePoint(EndingCoursePointViewModel endingCoursePoint, Guid userId) { if (endingCoursePoint != null) { try { await Task.Run(() => { endingCoursePoint.DateModified = DateTime.Now; endingCoursePoint.DateOnPoint = DateTime.Now; endingCoursePoint.AppUserId = userId; _endingCoursePointService.Add(endingCoursePoint); _endingCoursePointService.SaveChanges(); return(Ok("Thêm giáo viên thành công!")); }); } catch { throw new Exception(string.Format("Lỗi khi thêm dữ liệu")); } } return(CreatedAtAction("GetEndingCoursePoints()", new { id = endingCoursePoint.Id }, endingCoursePoint)); }