public async Task <IActionResult> AddTime([FromBody] JObject data)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var personnelId = data["PersonnelId"].Value <int>();
                    var timeType    = data["TimeType"].Value <int>();

                    if (timeType <= 0 || timeType >= 5)
                    {
                        var res = new RepResult <Day> {
                            Successed = false, Message = "نوع زمان ورودی مجاز نمی باشد", ResultObject = null
                        };;
                        return(BadRequest(res));
                    }
                    var dateTime = DateTime.Now;
                    var obj      = (await atdTimeRep.Add(personnelId, dateTime, (WorkTimeType)timeType));

                    if (obj.Successed)
                    {
                        var res = await dayRep.GetDayData(personnelId, dateTime);

                        if (res.Successed)
                        {
                            return(Ok(res.ResultObject));
                        }
                        else
                        {
                            return(NotFound(res));
                        }
                    }
                    else
                    {
                        return(NotFound(obj));
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
        public async Task <RepResult <MonthVM> > GetMonthData(int personnelId, string shamsiMonthDate)
        {
            if (dbContext != null)
            {
                var monthVm = new MonthVM();
                monthVm.PersonnelId = personnelId;

                PersianDateTime perDt      = PersianDateTime.Parse((shamsiMonthDate + "-01").Replace("-", "/"));
                DateTime        firstDayDt = perDt.ToDateTime();

                PersianCalendar pc = new PersianCalendar();
                monthVm.Year      = pc.GetYear(firstDayDt).ToString();
                monthVm.MonthName = getMonthName(pc.GetMonth(firstDayDt));

                var lenDays = pc.GetDaysInMonth(perDt.Year, perDt.Month);
                monthVm.Days     = new List <DayVM>();
                monthVm.Duration = new DurationVM();
                for (int i = 1; i < lenDays; i++)
                {
                    var dayDate = new DateTime(firstDayDt.Year, firstDayDt.Month, firstDayDt.Day);

                    if (i > 1)
                    {
                        dayDate = dayDate.AddDays(i);
                    }

                    var dayVm = (await dayRep.GetDayData(personnelId, dayDate)).ResultObject;

                    monthVm.Days.Add(dayVm);

                    monthVm.Duration.DurationOfWorkSecends     += dayVm.Duration.DurationOfWorkSecends;
                    monthVm.Duration.DurationOfLeaveSecends    += dayVm.Duration.DurationOfLeaveSecends;
                    monthVm.Duration.DurationOfMisiionSecends  += dayVm.Duration.DurationOfMisiionSecends;
                    monthVm.Duration.DurationOfOverTimeSecends += dayVm.Duration.DurationOfOverTimeSecends;
                }

                monthVm.Duration.DurationOfWork     = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(monthVm.Duration.DurationOfWorkSecends));
                monthVm.Duration.DurationOfLeave    = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(monthVm.Duration.DurationOfLeaveSecends));
                monthVm.Duration.DurationOfMisiion  = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(monthVm.Duration.DurationOfMisiionSecends));
                monthVm.Duration.DurationOfOverTime = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(monthVm.Duration.DurationOfOverTimeSecends));


                return(new RepResult <MonthVM> {
                    Successed = true, ResultObject = monthVm
                });
            }

            return(new RepResult <MonthVM>());
        }