示例#1
0
        public bool CheckDayType(Guid workScheduleId, DateTime date)
        {
            if (repoCalendar.Contains(x => x.WorkScheduleTableId == workScheduleId && x.Date == date))
            {
                СalendarTable calendar = repoCalendar.Find(x => x.WorkScheduleTableId == workScheduleId && x.Date == date);
                if (calendar.DateType == DateType.DayOff)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        // Calandar
        public void SaveDayToCalendar(Guid workScheduleId, DateTime date, string currentUserName = "")
        {
            string          localUserName = getCurrentUserName(currentUserName);
            ApplicationUser user          = _AccountService.FirstOrDefault(x => x.UserName == localUserName);
            СalendarTable   calendar;

            if (repoCalendar.Contains(x => x.WorkScheduleTableId == workScheduleId && x.Date == date))
            {
                calendar = repoCalendar.Find(x => x.WorkScheduleTableId == workScheduleId && x.Date == date);
                calendar.ModifiedDate = DateTime.UtcNow;
                calendar.ApplicationUserModifiedId = user.Id;
                if (calendar.DateType == DateType.DayOff)
                {
                    calendar.DateType = DateType.WorkingDay;
                }
                else
                {
                    calendar.DateType = DateType.DayOff;
                }

                _uow.GetRepository <СalendarTable>().Update(calendar);
            }
            else
            {
                calendar                           = new СalendarTable();
                calendar.Date                      = date;
                calendar.DateType                  = DateType.DayOff;
                calendar.WorkScheduleTableId       = workScheduleId;
                calendar.CreatedDate               = DateTime.UtcNow;
                calendar.ModifiedDate              = calendar.CreatedDate;
                calendar.ApplicationUserCreatedId  = user.Id;
                calendar.ApplicationUserModifiedId = user.Id;
                _uow.GetRepository <СalendarTable>().Add(calendar);
            }

            _uow.Save();
        }