Example #1
0
        public async Task <IActionResult> Update(UpdateSchduleRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _scheduleService.UpdateSchdule(request);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Example #2
0
        public async Task <ApiResult <bool> > UpdateSchdule(UpdateSchduleRequest request)
        {
            var schedule = await _context.Schedules.FindAsync(request.Id_Schedule);

            if (schedule == null)
            {
                return(new ApiErrorResult <bool>("Không tìm thấy lịch trình"));
            }
            schedule.Id_Course  = request.Id_Course;
            schedule.Id_Class   = request.Id_Class;
            schedule.Date       = request.DateBegin.Date;
            schedule.TimeBegin  = request.TimeBegin;
            schedule.TimeEnd    = request.TimeEnd;
            schedule.DateUpdate = DateTime.UtcNow.AddHours(7);
            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>("Cập nhật thành công"));
        }