Пример #1
0
        public bool ShouldCreateCardEntry(TimeCardEntry currentCardEntry, int timeCardAction)
        {
            var result = false;

            if (currentCardEntry != null && (DateTime.Compare(currentCardEntry.DateTime, DateTime.Today) > 0))
            {
                if (currentCardEntry.Action != timeCardAction)
                {
                    result = true;
                }
            }

            if (currentCardEntry == null && timeCardAction == 1) //Clock In
            {
                result = true;
            }

            return(result);
        }
Пример #2
0
        public static void UpdateTimeCardEntry(User user)
        {
            if (TimeCardAction == TimeCardEntry.TimeCardActionEnum.None)
            {
                return;
            }
            bool addEntry = false;
            //var ticketId = Dao.Select<Table, int>(x => x.TicketId, x => x.Name == SelectedTicket.LocationName).FirstOrDefault();
            var id = user.Id;
            TimeCardEntry currentTicket = GetLastTimeCardEntry(user);

            // var currentTicket = Dao.Last<TimeCardEntry>(x => x, x => (x.User.Id == user.Id && (DateTime.Compare(x.DateTime, DateTime.Today) > 0))).Last();

            if (currentTicket != null && (DateTime.Compare(currentTicket.DateTime, DateTime.Today) > 0))
            {

                var existingAction = (TimeCardEntry.TimeCardActionEnum) currentTicket.Action;
                if (existingAction != TimeCardAction)
                {
                    addEntry = true;
                }

            }
            if (currentTicket == null && TimeCardAction == TimeCardEntry.TimeCardActionEnum.ClockIn)
            {
                addEntry = true;
            }
            if (addEntry)
            {
                var timeCardEntry = new TimeCardEntry(TimeCardAction, user.Id);
                AddTimeCardEntry(timeCardEntry);

                if (TimeCardAction == TimeCardEntry.TimeCardActionEnum.ClockOut)
                {
                    AppServices.LogoutUser();
                    return;
                }

            }

            TimeCardAction = TimeCardEntry.TimeCardActionEnum.None;
        }
Пример #3
0
        /// <summary>
        /// Add Time Card Entry
        /// </summary>
        /// <param name="entry"></param>
        public static void AddTimeCardEntry(TimeCardEntry timeCardEntry)
        {
            using (var workspace = WorkspaceFactory.Create())
            {

                workspace.Add(timeCardEntry);
                workspace.CommitChanges();
            }
        }
Пример #4
0
        public bool ShouldCreateCardEntry(TimeCardEntry currentCardEntry, int timeCardAction)
        {
            var result = false;

            if (currentCardEntry != null && (DateTime.Compare(currentCardEntry.DateTime, DateTime.Today) > 0))
            {
                if (currentCardEntry.Action != timeCardAction)
                {
                    result = true;
                }
            }

            if (currentCardEntry == null && timeCardAction == 1) //Clock In
            {
                result = true;
            }

            return result;
        }
Пример #5
0
 public TimeCardEntry CreateTimeCardEntry(int timeCardAction)
 {
     return(TimeCardEntry.Crate(timeCardAction, Id));
 }