Exemplo n.º 1
0
        public void GetAttendance_WhenCalled_ShouldReturnAttendanceWithGigIdAndAttendeeId()
        {
            var attendance = new Attendance {
                AttendeeId = "1", GigId = 1
            };

            _mockAttendances.SetSource(new[] { attendance });

            var attendanceFromRepository = _repository.GetAttendance(2, "1");

            attendanceFromRepository.Should().BeNull();
        }
Exemplo n.º 2
0
        public ActionResult Show(DateTime?d)
        {
            DateTime date = DateTime.Today;

            if (d != null)
            {
                date = d.Value;
            }
            string dateStr    = date.ToString("dd-MM-yyyy");
            var    attendance = AttendanceRepository.GetAttendance(date, this.CurrentUser.Class_id);

            int             day      = (int)date.DayOfWeek;
            List <Schedule> schedule = new List <Schedule>();

            if (date.Month >= 2 && date.Month <= 6)
            {
                schedule = ScheduleRepository.GetSchedule(2, this.CurrentUser.Class_id).Where(s => s.Day == day).ToList();
            }
            else if ((date.Month >= 9 && date.Month <= 12) || date.Month == 1)
            {
                schedule = ScheduleRepository.GetSchedule(1, this.CurrentUser.Class_id).Where(s => s.Day == day).ToList();
            }

            AttendanceViewModel vm = new AttendanceViewModel()
            {
                AllAttendances = attendance,
                AllSchedule    = schedule,
                Date           = dateStr,
                Date2          = date,
                Periods        = new PeriodAttendance[7]
            };

            return(View(vm));
        }
Exemplo n.º 3
0
        public IHttpActionResult EditAttendance(DateModal dtm)
        {
            if (dtm.employeeId == Guid.Empty)
            {
                dtm.employeeId = Guid.Parse(GetUserId());
            }
            DateTime Date = DateTime.Parse(dtm.attendanceDate);
            //DateTime.Parse(dtm.monthStartDate);
            int?    day   = null;
            int     year  = Convert.ToDateTime(dtm.attendanceDate).Year;
            int     month = Convert.ToDateTime(dtm.attendanceDate).Month;
            DataSet ds    = AttendanceRepository.GetAttendance(dtm.employeeId, Convert.ToInt32(dtm.todayDay) == 0 ? day : Convert.ToInt32(dtm.todayDay), Date.Month, Date.Year);

            ds.Tables[0].TableName = "Attendance";
            DataTable dt = BindTotalTime(GetUserId(), dtm.attendanceDate);

            if (dt.Rows.Count > 0)
            {
                dt.TableName = "TotalHours";
                ds.Tables.Add(dt.Copy());
            }
            DataTable Results = ds.Tables[0];
            var       query   = Results.AsEnumerable().Select(Result => new
            {
                Attendance     = Result.Field <decimal>("Attendance"),
                AttendanceId   = Result.Field <Guid?>("AttendanceId"),
                Date           = Result.Field <DateTime>("Date").ToString("MM-dd-yyyy"),
                DayDescription = Result.Field <string>("DayDescription"),
                EmployeeId     = Result.Field <Guid>("EmployeeId"),
                InTime         = Result.Field <DateTime?>("InTime"),
                IsWorkFromHome = Result.Field <Boolean>("IsWorkFromHome"),
                OutTime        = Result.Field <DateTime?>("OutTime"),
                Remarks        = Result.Field <string>("Remarks"),
                TotalTime      = Result.Field <string>("TotalTime"),
                Type           = Result.Field <string>("Type"),
                //id = Result.Field<string>("id"),
                //internalId=Result.Field<string>("internalId")
            });

            var singleresult = query.Where(m => m.EmployeeId == dtm.employeeId && m.Date == dtm.attendanceDate);

            return(Ok(singleresult));
        }
Exemplo n.º 4
0
        public ActionResult Details(int id)
        {
            DetailsViewModel viewModel = new DetailsViewModel();

            viewModel.Gig = gigRepository.GetGigWithArtistAndGenre(id);

            if (User.Identity.IsAuthenticated)
            {
                string userId = User.Identity.GetUserId();

                viewModel.Attendance = attendanceRepository.GetAttendance(userId, id) != null;
                viewModel.Following  = followingRepository.GetFollowing(userId, viewModel.Gig.ArtistId) != null;
            }
            else
            {
                viewModel.Attendance = false;
                viewModel.Following  = false;
            }


            return(View(viewModel));
        }
Exemplo n.º 5
0
        public ActionResult Details(string id)
        {
            var mahfil = _mahfilMepository.GetMahfil(id);

            if (mahfil == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new MahfilDetailsViewModel()
            {
                Congregration = mahfil
            };

            if (User.Identity.IsAuthenticated)
            {
                var userId = User.Identity.GetUserId();
                viewModel.IsAttending = _attendanceRepository.GetAttendance(mahfil.Id, userId) != null;
                viewModel.IsFollowing = _followingRepository.GetFollowing(userId, mahfil.SpeakerId) != null;
            }

            return(View("Details", viewModel));
        }
Exemplo n.º 6
0
        public ActionResult Details(int id)
        {
            var gig = _gigRepository.GetSingleGig(id);

            if (gig == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new GigDetailsViewModel {
                Gig = gig
            };

            if (User.Identity.IsAuthenticated)
            {
                var userId = User.Identity.GetUserId();

                viewModel.isAttending = _attendanceRepository.GetAttendance(userId, gig.Id) != null;
                viewModel.isFollowing = _attendanceRepository.GetFollowing(userId, gig.ArtistId) != null;
            }

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public IHttpActionResult GetAttendance(DateModal dtm)
        {
            if (dtm.employeeId == Guid.Empty)
            {
                dtm.employeeId = Guid.Parse(GetUserId());
            }
            DateTime startDate = DateTime.Parse(dtm.monthStartDate);
            //DateTime.Parse(dtm.monthStartDate);
            int?    day   = null;
            int     year  = Convert.ToDateTime(dtm.monthStartDate).Year;
            int     month = Convert.ToDateTime(dtm.monthStartDate).Month;
            DataSet ds    = AttendanceRepository.GetAttendance(dtm.employeeId, Convert.ToInt32(dtm.todayDay) == 0 ? day : Convert.ToInt32(dtm.todayDay), startDate.Month, startDate.Year);

            ds.Tables[0].TableName = "Attendance";
            DataTable dt = BindTotalTime(GetUserId(), dtm.monthStartDate);

            if (dt.Rows.Count > 0)
            {
                dt.TableName = "TotalHours";
                ds.Tables.Add(dt.Copy());
            }
            return(Ok(ds));
            //return Ok(JsonConvert.SerializeObject(ds, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));
        }
Exemplo n.º 8
0
 // GET: api/Attendance
 /// <summary>
 /// Gets all attendances
 /// </summary>
 /// <returns>List of AttendanceModel</returns>
 public List <AttendanceModel> Get()
 {
     return(_attendanceRepository.GetAttendance());
 }