public async Task <CalendarScheduleViewModel> GetCalendarScheduleAsync(string language)
        {
            var data = new CalendarScheduleViewModel();

            data.message = new messageModel();
            try
            {
                var userId = JwtHelper.GetUserIdFromToken(HttpContext);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }
                using (var context = new StandardcanContext())
                {
                    var jsonData = JsonConvert.SerializeObject(new
                    {
                        emp_id = userId,
                        lang   = language,
                    });
                    SystemLog systemLog = new SystemLog()
                    {
                        module   = "api/CalendarHoliday/GetCalendarSchedule",
                        data_log = jsonData
                    };
                    await _systemLogService.InsertSystemLogAsync(systemLog);

                    SqlParameter emp_id = new SqlParameter("emp_id", userId ?? "");
                    SqlParameter lang   = new SqlParameter("lang", language ?? "");

                    var spData = context.SpMbGetSchedule.FromSqlRaw("sp_mb_get_schedule @emp_id", emp_id).ToList();
                    //context.SpMbEmpOTHoursResult.FromSqlRaw("sp_mb_emp_ot_hours @emp_id, @s_start_date, @s_stop_date, @lang", emp_id, s_start_date, s_stop_date, lang).ToList();
                    data.calendarschedule_list = new List <CalendarSchedule>();
                    foreach (var item in spData)
                    {
                        CalendarSchedule calendarHoliday = new CalendarSchedule();
                        calendarHoliday.startTime = item.startTime;
                        calendarHoliday.endTime   = item.endTime;
                        calendarHoliday.title     = item.title;
                        calendarHoliday.remark    = item.remark;
                        data.calendarschedule_list.Add(calendarHoliday);
                    }
                    data.message.status = "1";
                    data.message.msg    = "Success";
                }
            }
            catch (Exception ex)
            {
                data.message.status = "2";
                data.message.msg    = ex.Message;
            }
            return(data);
        }
Example #2
0
        public void GetNextOccurrenceTest()
        {
            CalendarSchedule target = new CalendarSchedule();
            //target
            //.StartDailyAt(new TimeOfDay { Hour = 9, Minute = 52 })
            //.EndingAt(new DateTime(2012, 1, 6, 11, 02, 59))
            //.WithRepeatInterval(new TimeSpan(0, 3, 0))
            //.OnDaysOfWeek(new System.Collections.Generic.HashSet<DayOfWeek> { DayOfWeek.Friday });
            //.OnDaysOfMonth(new System.Collections.Generic.HashSet<int> { 7 });
            DateTime            afterDateTime = DateTime.Now;
            Nullable <DateTime> expected      = new Nullable <DateTime>();      // TODO: Initialize to an appropriate value
            Nullable <DateTime> actual;

            actual = target.GetNextOccurrence(afterDateTime);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }