public TMSAttendance AddFromGlobal(TMSAttendanceCreateViewModel Vm)
        {
            var entity = _mapper.Map <TMSAttendanceCreateViewModel, TMSAttendance>(Vm);

            _tmsAttendanceRepository.Add(entity);
            var attendanceGlobal = _attendanceRepository.Get(Vm.AttendanceId);

            if (attendanceGlobal != null)
            {
                attendanceGlobal.Used = 1;
                if (string.IsNullOrEmpty(attendanceGlobal.CompanyUsed))
                {
                    attendanceGlobal.CompanyUsed = "";
                }
                List <string> listCompanyUsed = attendanceGlobal.CompanyUsed.Split(';').ToList();
                if (!listCompanyUsed.Contains(Vm.CompanyId.ToString()))
                {
                    listCompanyUsed.Add(Vm.CompanyId.ToString());
                }
                attendanceGlobal.CompanyUsed = string.Join(";", listCompanyUsed.ToArray());
                _attendanceRepository.Update(attendanceGlobal);
            }
            SaveChanges();
            return(entity);
        }
Пример #2
0
        public IHttpActionResult GetAttendance(int id)
        {
            Attendance Attendance = AttendanceRepo.Get(id);

            if (Attendance == null)
            {
                return(NotFound());
            }



            AttendanceDTO AttendanceDTO = Mapper.Map <AttendanceDTO>(Attendance);

            return(Ok(AttendanceDTO));
        }
Пример #3
0
        public async Task <IActionResult> UpdateAttendacne(int id, [FromBody] AttendanceResource AttendanceResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Attendance attendance = await _repo.Get(id);

            if (attendance == null)
            {
                return(NotFound());
            }
            _mapper.Map <AttendanceResource, Attendance>(AttendanceResource, attendance);
            await _unitofwork.CompleteAsync();

            return(StatusCode(202));
        }
Пример #4
0
        private void GetSwapingDate(Pair <long?> termPair)
        {
            var term = new Pair <Term>();

            if (termPair.Applier.HasValue)
            {
                term.Applier = _attendanceRepository.Get <Term>(termPair.Applier);
            }
            if (termPair.Replier.HasValue)
            {
                term.Replier = _attendanceRepository.Get <Term>(termPair.Replier);
            }
            Applier.SwapingDate = Replier.SwapingDate = term.Applier.Get(term.Replier);
            _attendanceRepository.Clear();
        }
Пример #5
0
        public AttendanceViewModel GetById(int id)
        {
            var model = _attendanceRepository.Get(id);

            return(_mapper.Map <Attendance, AttendanceViewModel>(model));
        }