Example #1
0
        public async Task TestAddUpdatDelete()
        {
            TimeAndAttendanceSetupModule TimeAndAttendanceSetupMod = new TimeAndAttendanceSetupModule();

            TimeAndAttendanceSetupView view = new TimeAndAttendanceSetupView()
            {
                TimeZone        = "Mountain Standard Time",
                DaylightSavings = true,
                Offset          = -7
            };
            NextNumber nnNextNumber = await TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.Query().GetNextNumber();

            view.TimeAndAttendanceSetupNumber = nnNextNumber.NextNumberValue;

            TimeAndAttendanceSetup timeAndAttendanceSetup = await TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.Query().MapToEntity(view);

            TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.AddTimeAndAttendanceSetup(timeAndAttendanceSetup).Apply();

            TimeAndAttendanceSetup newTimeAndAttendanceSetup = await TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.Query().GetEntityByNumber(view.TimeAndAttendanceSetupNumber);

            Assert.NotNull(newTimeAndAttendanceSetup);

            newTimeAndAttendanceSetup.TimeZone = "Pacific Update";

            TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.UpdateTimeAndAttendanceSetup(newTimeAndAttendanceSetup).Apply();

            TimeAndAttendanceSetupView updateView = await TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.Query().GetViewById(newTimeAndAttendanceSetup.TimeAndAttendanceSetupId);

            Assert.Same(updateView.TimeZone, "Pacific Update");
            TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.DeleteTimeAndAttendanceSetup(newTimeAndAttendanceSetup).Apply();
            TimeAndAttendanceSetup lookupTimeAndAttendanceSetup = await TimeAndAttendanceSetupMod.TimeAndAttendanceSetup.Query().GetEntityById(view.TimeAndAttendanceSetupId);

            Assert.Null(lookupTimeAndAttendanceSetup);
        }
Example #2
0
        private async Task <int> GetDuration(string punchinString, string punchOutString, int mealDeduction)
        {
            int      minutes = 0;
            string   timeIn, timeOut;
            bool     standardToDayLightSaving = false;
            bool     dayLightSavingToStandard = false;
            DateTime fromTime;
            DateTime toTime;

            try
            {
                timeIn   = ReverseDate(punchinString) + " " + ReverseTranslate24hr(punchinString);
                fromTime = DateTime.Parse(timeIn);
                timeOut  = ReverseDate(punchOutString) + " " + ReverseTranslate24hr(punchOutString);
                toTime   = DateTime.Parse(timeOut);
                if (timeIn.Trim() != "" && timeOut.Trim() != "")
                {
                    minutes = (int)(toTime - fromTime).TotalMinutes;
                    DateTime mst = toTime;

                    TimeAndAttendanceSetup setup = await GetTimeAndAttendanceTimeZone();

                    TimeZoneInfo localTime = TimeZoneInfo.FindSystemTimeZoneById(setup.TimeZone); //TimeZoneInfo.Local.StandardName

                    TimeSpan offset = localTime.GetUtcOffset(mst);

                    mst = DateTime.Now.ToUniversalTime().AddHours(offset.Hours).ToUniversalTime();

                    if (localTime.IsDaylightSavingTime(fromTime) == true &&
                        localTime.IsDaylightSavingTime(toTime) == false)
                    {
                        dayLightSavingToStandard = true;
                    }

                    if (localTime.IsDaylightSavingTime(fromTime) == false &&
                        localTime.IsDaylightSavingTime(toTime) == true)
                    {
                        standardToDayLightSaving = true;
                    }

                    if (dayLightSavingToStandard)
                    {
                        minutes += 60;
                    }

                    if (standardToDayLightSaving)
                    {
                        minutes += 60;
                    }
                }

                minutes = minutes - mealDeduction;

                return(minutes);
            }
            catch (Exception ex)
            {
                throw new Exception(GetMyMethodName(), ex);
            }
        }
Example #3
0
        public async Task <IActionResult> DeleteTimeAndAttendanceSetup([FromBody] TimeAndAttendanceSetupView view)
        {
            TimeAndAttendanceSetupModule invMod = new TimeAndAttendanceSetupModule();
            TimeAndAttendanceSetup       timeAndAttendanceSetup = await invMod.TimeAndAttendanceSetup.Query().MapToEntity(view);

            invMod.TimeAndAttendanceSetup.DeleteTimeAndAttendanceSetup(timeAndAttendanceSetup).Apply();

            return(Ok(view));
        }
Example #4
0
        public async Task <IActionResult> AddTimeAndAttendanceSetup([FromBody] TimeAndAttendanceSetupView view)
        {
            TimeAndAttendanceSetupModule invMod = new TimeAndAttendanceSetupModule();

            NextNumber nnTimeAndAttendanceSetup = await invMod.TimeAndAttendanceSetup.Query().GetNextNumber();

            view.TimeAndAttendanceSetupNumber = nnTimeAndAttendanceSetup.NextNumberValue;

            TimeAndAttendanceSetup timeAndAttendanceSetup = await invMod.TimeAndAttendanceSetup.Query().MapToEntity(view);

            invMod.TimeAndAttendanceSetup.AddTimeAndAttendanceSetup(timeAndAttendanceSetup).Apply();

            TimeAndAttendanceSetupView newView = await invMod.TimeAndAttendanceSetup.Query().GetViewByNumber(view.TimeAndAttendanceSetupNumber);


            return(Ok(newView));
        }
Example #5
0
        public async Task <TimeAndAttendanceTimeView> GetUTCAdjustedTime()
        {
            try
            {
                TimeAndAttendanceTimeView utcTime = new TimeAndAttendanceTimeView();

                DateTime mst = DateTime.Now;

                TimeZoneInfo localTime;

                TimeAndAttendanceSetup setup = await GetTimeAndAttendanceTimeZone();

                localTime = TimeZoneInfo.FindSystemTimeZoneById(setup.TimeZone); //TimeZoneInfo.Local.StandardName

                TimeSpan offset = localTime.GetUtcOffset(mst);

                //bool isDaylightSaving = localTime.IsDaylightSavingTime(mst);

                mst = DateTime.Now.ToUniversalTime().AddHours(offset.Hours).ToUniversalTime();

                utcTime.PunchDate = mst;

                string year    = mst.Year.ToString();
                string month   = Utilities.Right("0" + mst.Month.ToString(), 2);
                string day     = Utilities.Right("0" + mst.Day.ToString(), 2);
                string hours   = Utilities.Right("0" + mst.Hour.ToString(), 2);
                string minutes = Utilities.Right("0" + mst.Minute.ToString(), 2);
                string seconds = Utilities.Right("0" + mst.Second.ToString(), 2);

                utcTime.PunchDateTime = year + month + day + hours + minutes + seconds;
                return(utcTime);
            }
            catch (Exception ex)
            {
                throw new Exception(GetMyMethodName(), ex);
            }
        }
Example #6
0
 public IFluentTimeAndAttendanceSetup DeleteTimeAndAttendanceSetup(TimeAndAttendanceSetup deleteObject)
 {
     unitOfWork.timeAndAttendanceSetupRepository.DeleteObject(deleteObject);
     this.processStatus = CreateProcessStatus.Delete;
     return(this as IFluentTimeAndAttendanceSetup);
 }
Example #7
0
 public IFluentTimeAndAttendanceSetup AddTimeAndAttendanceSetup(TimeAndAttendanceSetup newObject)
 {
     unitOfWork.timeAndAttendanceSetupRepository.AddObject(newObject);
     this.processStatus = CreateProcessStatus.Insert;
     return(this as IFluentTimeAndAttendanceSetup);
 }