public Attendance CreateAttendance(Attendance attendance)
        {
            //if (!ModelState.IsValid)
            //{
            //    throw new HttpResponseException(HttpStatusCode.BadRequest);
            //}
            //_context.Attendances.Add(attendance);
            //_context.SaveChanges();

            //return attendance;
            return(_context.CreateAttendance(attendance));
        }
        public IActionResult CreateAttendance([FromBody] AttendanceDto Attendance)
        {
            if (Attendance == null)
            {
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_AttendanceRepository.CreateAttendance(Attendance))
            {
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }
Beispiel #3
0
        public void StartLaboratoryBasedOnValue(Guid factionId, int labValue)
        {
            var laboratory  = Guid.NewGuid();
            var studentList = _service.GetUsersByFactionId(factionId);
            var getUser     = _userRepo.GetAllUsers().FirstOrDefault(user => user.FactionId == factionId);
            var check       = _attendance.GetAllAttendances()
                              .Where(attend => attend.UserId == getUser.Id && attend.LaboratoryNumber == labValue).ToList().Count;

            if (check == 0)
            {
                foreach (var students in studentList)
                {
                    _attendance.CreateAttendance(
                        Attendance.CreateAttendance(
                            labValue,
                            laboratory,
                            students.Id,
                            0,
                            0,
                            false
                            ));
                }
            }
        }