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); }
// 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(); }