public async Task <ActionResult> CreateOrUpdate([FromBody] Point point) { if (await IsPointInvalid(point.PointNumber)) { return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Số điểm không hợp lệ" })); } else if (point.Id == default(int)) { await pointRepository.Create(point); return(Ok(new { status = ResultStatus.STATUS_OK, data = point })); } else { var existPoint = await pointRepository.Get(point.Id); if (existPoint == null) { await pointRepository.Create(point); return(Ok(new { status = ResultStatus.STATUS_OK, data = point })); } else { if (point.Subject != null) { existPoint.Subject = point.Subject; } existPoint.Student = point.Student; existPoint.Semester = point.Semester; existPoint.SchoolYear = point.SchoolYear; existPoint.PointType = point.PointType; existPoint.PointNumber = point.PointNumber; return(Ok(new { status = ResultStatus.STATUS_OK, data = point })); } } }
public void Create(PointViewModel point) { Point newPoint = _mapper.Map <Point>(point); repository.Create(newPoint); }