public ActionResult AddRehearsalPart(AdminHomeVM vm) { PeriodBuilder builder = new PeriodBuilder(); builder.Minutes = vm.NewRehearsalPart.IntLengthMinutes; vm.NewRehearsalPart.DurLength = builder.Build(); GetDAL get = new GetDAL(); get.OpenConnection(); foreach (var id in vm.NewRehearsalPart.ArrMemberNeededIDs) { Users tmpUser = get.GetUserByID(id); vm.NewRehearsalPart.LstMembers.Add(tmpUser); } get.CloseConnection(); InsertDAL insert = new InsertDAL(); insert.OpenConnection(); int newRehearsalPartID = insert.InsertRehearsalPart(vm.NewRehearsalPart); vm.NewRehearsalPart.IntRehearsalPartID = newRehearsalPartID; foreach (var m in vm.NewRehearsalPart.LstMembers) { AttendancePlanned ap = new AttendancePlanned(vm.NewRehearsalPart, m); insert.InsertAttendancePlanned(ap); } insert.CloseConnection(); return(RedirectToAction("Index")); }
// GET: Reports public ActionResult Index() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { ReportsHomeVM model = new ReportsHomeVM(); GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllRehearsalParts = get.GetAllRehearsalParts(); model.LstAllEvents = get.GetEventsByUser(Globals.LOGGED_IN_USER.IntUserID); model.LstAllRehearsals = new List <Rehearsal>(); foreach (Event e in model.LstAllEvents) { get.CloseConnection(); get.OpenConnection(); model.LstAllRehearsals.AddRange(get.GetRehearsalsByEvent(e)); } get.CloseConnection(); foreach (Rehearsal r in model.LstAllRehearsals) { r.DateWithEvent = r.Event.StrName + " " + r.DtmStartDateTime; } return(View("ReportsHome", model)); } }
// GET: Callboard public ActionResult Index() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { CallboardHomeVM model = new CallboardHomeVM(); model.CurrentUser = Globals.LOGGED_IN_USER; GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllCallboards = new List <Callboard>(); foreach (Event e in model.CurrentUser.LstEvents) { List <Callboard> callboards = get.GetCallboardsByEvent(e); model.LstAllCallboards.AddRange(callboards); } if (model.LstAllCallboards != null) { model.LstAllCallboards.Sort(); } model.LstAdminEvents = get.GetAdminEventsByUser(model.CurrentUser.IntUserID); get.CloseConnection(); return(View("CallboardHome", model)); } }
public ActionResult CheckUserIn(int intUserID) { GetDAL get = new GetDAL(); get.OpenConnection(); Users u = get.GetUserByID(intUserID); get.CloseConnection(); get.OpenConnection(); List <AttendancePlanned> apList = get.GetAttendancePlannedByRehearsalPart(ChosenRehearsalPart); // join query here get.CloseConnection(); InsertDAL insert = new InsertDAL(); insert.OpenConnection(); foreach (AttendancePlanned ap in apList) { if (u.Equals(ap.User)) { insert.InsertAttendanceActual(new AttendanceActual(DateTime.Now, true, ap)); UsersNotCurrentlyAtRehearsal.Remove(u); } } get.CloseConnection(); insert.CloseConnection(); return(RedirectToAction("Index")); }
// GET: CheckInOut public ActionResult Index() { if (!Globals.IS_ADMIN) { return(RedirectToAction("Index", "Home")); } else if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { CheckInOutVM model = new CheckInOutVM(); GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAdminEvents = get.GetAdminEventsByUser(Globals.LOGGED_IN_USER.IntUserID); foreach (Event e in model.LstAdminEvents) { e.LstRehearsalParts = get.GetRehearsalPartsByEvent(e); foreach (RehearsalPart rp in e.LstRehearsalParts) { rp.LstMembers = get.GetUsersByRehearsalPart(rp); } e.MembersForToday = LstAllMembersForRehearsalParts(e, get); } get.CloseConnection(); return(View("Index", model)); } }
// GET: Profile public ActionResult Index(bool IsInvalidAttempt = false) { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { ProfileHomeVM model = new ProfileHomeVM(); model.CurrentUser = Globals.LOGGED_IN_USER; model.EditedUserProfile = model.CurrentUser; model.IsInvalidPasswordAttempt = IsInvalidAttempt; GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllEvents = get.GetAllEvents(); var equalityComparer = new EventEqualityComparer(); IEnumerable <Event> difference = model.LstAllEvents.Except(model.CurrentUser.LstEvents, equalityComparer); model.LstEventsToJoin = difference.ToList(); get.CloseConnection(); return(View("ProfileHome", model)); } }
private ActionResult SendEmail(Callboard c) { MailMessage mail = new MailMessage(); GetDAL get = new GetDAL(); get.OpenConnection(); foreach (Users u in get.GetUsersByEvent(get.GetEventByID(c.Event.IntEventID))) { mail.To.Add(u.StrEmail); } get.CloseConnection(); mail.From = new MailAddress("*****@*****.**"); mail.Subject = c.StrSubject; mail.Body = "From: " + c.PostedByUser.StrName + " in " + c.Event.StrName; if (c.StrNote != null) { mail.Body += "\n\n" + c.StrNote; } mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("ensemble395", "7GStz.pPy.6AfX[t"); smtp.EnableSsl = true; smtp.Send(mail); return(RedirectToAction("Index")); }
// returns true if new user is created successfully public static bool CreateUser(Users newUser) { GetDAL getDAL = new GetDAL(); getDAL.OpenConnection(); Users usr = getDAL.GetUserByName(newUser.StrName); // if no user found by username if (usr == null) { // prompt for name, email, phone, eventID // get email string email = newUser.StrEmail; if (!IsValidEmail(email)) { return(false); } // get phone string phone = newUser.StrPhone; if (phone.Length != 10) { return(false); } InsertDAL insertDAL = new InsertDAL(); insertDAL.OpenConnection(); // generate random number for salt and convert it to a byte array for key byte[] salt = BitConverter.GetBytes(new Random().Next()); byte[] key; try { key = ComputeSHA256Hash(newUser.StrPassword, salt); } catch (ArgumentNullException) { return(false); } int intNewUserID = insertDAL.InsertUser(new Users(newUser.StrName, salt, key, email, phone)); insertDAL.CloseConnection(); GetDAL get = new GetDAL(); get.OpenConnection(); Users completeUser = get.GetUserByID(intNewUserID); get.CloseConnection(); return(LoginUser(completeUser)); } getDAL.CloseConnection(); return(false); }
public frmPlay(int setupState) { InitializeComponent(); this.chucNang = (menuChucNang)setupState; getData = new GetDAL(); setData = new SetDAL(); }
void LoadGameByGameSaved(int ma, List <Cell> lstCell, int tg) { getData = new GetDAL(); c = getData.GetLevelByMa(ma); lblSoMinFlag.Text = c.soMin.ToString(); board = new Board(pnlLayOut, pnlPlay, (int)c.soCot, (int)c.soDong, (int)c.soMin, pnlPlayState, (int)chucNang); board.SetupBoardCoSan(lstCell, tg); }
void LoadGame(int ma) { getData = new GetDAL(); c = getData.GetLevelByMa(ma); lblSoMinFlag.Text = c.soMin.ToString(); board = new Board(pnlLayOut, pnlPlay, (int)c.soCot, (int)c.soDong, (int)c.soMin, pnlPlayState, (int)chucNang); board.SetupBoard(false); board.PlaceMines(); }
public Schedule(List <RehearsalPart> allRehearsalParts, Event @event) { UnscheduledRehearsalParts = allRehearsalParts.OrderBy(x => x.IntPriority).ToList(); GetDAL get = new GetDAL(); get.OpenConnection(); EventSchedule = get.GetEventScheduleByEvent(@event.IntEventID); CreateSchedule(DateTime.Now.AddDays(1), @event.DtmDate, get); }
void LoadGameBySetup() { btnStart.Enabled = true; getData = new GetDAL(); CapDo c = getData.GetLevelByMa((int)cboLevel.SelectedValue); lblSoMinFlag.Text = c.soMin.ToString(); board = new Board(pnlLayOut, pnlPlay, (int)c.soCot, (int)c.soDong, (int)c.soMin, pnlPlayState, (int)chucNang); board.pnlPlay.Controls.Clear(); board.SetupBoard(true); }
public ActionResult Login(bool isInvalidPasswordAttempt = false) { LoginVM model = new LoginVM(); model.IsInvalidPasswordAttempt = isInvalidPasswordAttempt; GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllEvents = get.GetAllEvents(); get.CloseConnection(); return(View("Login", model)); }
// GET: Admin public ActionResult Index() { if (Globals.IS_ADMIN) { AdminHomeVM model = new AdminHomeVM(); GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllGroups = get.GetAllGroups(); model.LstAllEvents = get.GetAllEvents(); model.LstAdminEvents = get.GetAdminEventsByUser(Globals.LOGGED_IN_USER.IntUserID); foreach (Event e in model.LstAdminEvents) { e.LstRehearsalParts = get.GetRehearsalPartsByEvent(e); foreach (RehearsalPart rp in e.LstRehearsalParts) { rp.LstMembers = get.GetUsersByRehearsalPart(rp); if (rp.DtmStartDateTime.Equals(DateTime.MinValue)) { rp.DtmStartDateTime = null; } if (rp.DtmEndDateTime.Equals(DateTime.MinValue)) { rp.DtmEndDateTime = null; } } } model.LstAllTypes = get.GetAllTypes(); model.LstAllUsersForAdminEvents = get.GetAllUsersForAdminEvents(model.LstAdminEvents); get.CloseConnection(); get.OpenConnection(); foreach (Users u in model.LstAllUsersForAdminEvents) { u.LstConflicts = get.GetConflictsByUser(u).OrderBy(x => x.DtmStartDateTime).ToList(); } get.CloseConnection(); return(View("AdminHome", model)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult CreateNewSchedule(ScheduleHomeVM vm) { GetDAL get = new GetDAL(); get.OpenConnection(); Event e = get.GetEventByID(vm.SelectedEvent.IntEventID); List <RehearsalPart> rehearsalParts = get.GetRehearsalPartsByEvent(e); foreach (RehearsalPart rp in rehearsalParts) { rp.LstMembers = get.GetUsersByRehearsalPart(rp); } get.CloseConnection(); //List<RehearsalPart> rehearsalParts = vm.LstAllRehearsalParts.Where(x => x.Event.Equals(e)).ToList(); Schedule newSchedule = new Schedule(rehearsalParts, e); ScheduleViewVM model = new ScheduleViewVM(); model.Schedule = newSchedule.FinalSchedule; tmpRehearsalPartsSchedule = model.Schedule; foreach (LocalDate d in uniqueDatesOfRehearsals(model.Schedule.LstScheduledRehearsalParts)) { Rehearsal tmpRehearsal = new Rehearsal(); // get earliest rehearsal on any day DateTime fromDateOnly = new DateTime(d.Year, d.Month, d.Day); // get start of earliest rehearsal part on that day RehearsalPart earliest = model.Schedule.LstScheduledRehearsalParts.Where(x => x.DtmStartDateTime.GetValueOrDefault().Date.Equals(fromDateOnly)).OrderBy(x => x.DtmStartDateTime.GetValueOrDefault()).FirstOrDefault(); tmpRehearsal.DtmStartDateTime = earliest.DtmStartDateTime.GetValueOrDefault(); // get end of latest rehearsal part on that day RehearsalPart lastest = model.Schedule.LstScheduledRehearsalParts.Where(x => x.DtmEndDateTime.GetValueOrDefault().Date.Equals(fromDateOnly)).OrderByDescending(x => x.DtmEndDateTime.GetValueOrDefault()).FirstOrDefault(); tmpRehearsal.DtmEndDateTime = lastest.DtmEndDateTime.GetValueOrDefault(); tmpRehearsal.LstRehearsalParts = model.Schedule.LstScheduledRehearsalParts.Where(x => x.DtmStartDateTime.GetValueOrDefault().Date.Equals(fromDateOnly)).ToList(); model.LstTmpRehearsals.Add(tmpRehearsal); } return(View("ScheduleView", model)); }
////add text to GenerateReport.cshtml public ActionResult MakeReport(ReportsHomeVM vm) { ReportsHomeVM model = new ReportsHomeVM(); if (vm.ChosenRehearsal == null) { vm.ChosenRehearsal = new Rehearsal(Globals.rID); } GetDAL get = new GetDAL(); get.OpenConnection(); Rehearsal r = get.GetRehearsalByID(vm.ChosenRehearsal.IntRehearsalID); Globals.rID = r.IntRehearsalID; //Rehearsal r = vm.ChosenRehearsal; List <RehearsalPart> rehearsalPartsForToday = get.GetRehearsalPartsByRehearsal(r); model.EventName = r.Event.StrName;; model.GroupName = r.Event.Group.StrName; model.Location = r.StrLocation; model.StartTime = r.DtmStartDateTime.ToString(); model.EndTime = r.DtmEndDateTime.ToString(); model.RehearsalDate = r.DtmStartDateTime.Date.ToString(); foreach (RehearsalPart rp in rehearsalPartsForToday) { rp.AttendancePlanned = get.GetAttendancePlannedByRehearsalPart(rp); rp.AttendanceActual = new List <AttendanceActual>(); foreach (AttendancePlanned ap in rp.AttendancePlanned) { rp.AttendanceActual = rp.AttendanceActual.Concat(get.GetAttendanceActualByPlanned(ap)).ToList(); } } model.Notes = r.StrNotes; model.LstAllRehearsalParts = rehearsalPartsForToday; get.CloseConnection(); Globals.PDF = model; return(View("GenerateReport", model)); }
public ActionResult ChooseEvent(CheckInOutVM c) { GetDAL get = new GetDAL(); get.OpenConnection(); ChosenEvent = get.GetEventByID(c.ChosenEvent.IntEventID); LstRehearsalParts = get.GetRehearsalPartsByEvent(c.ChosenEvent); CheckInOutMidVM model = new CheckInOutMidVM { ChosenEvent = ChosenEvent, LstRehearsalParts = LstRehearsalParts }; get.CloseConnection(); return(View("CheckInOutMid", model)); }
public ActionResult ChooseRehearsalPart(CheckInOutMidVM vm) { GetDAL get = new GetDAL(); get.OpenConnection(); ChosenRehearsalPart = get.GetRehearsalPartByID(vm.ChosenRehearsalPart.IntRehearsalPartID); UsersNotCurrentlyAtRehearsal = get.GetUsersByRehearsalPart(ChosenRehearsalPart); CheckInOutViewVM model = new CheckInOutViewVM { CurrentRehearsalPart = ChosenRehearsalPart, UsersNotCurrentlyAtRehearsal = UsersNotCurrentlyAtRehearsal }; get.CloseConnection(); return(View("CheckInOutView", model)); }
/*public ActionResult CheckUserOut(CheckInOutViewVM vm) * { * GetDAL get = new GetDAL(); * get.OpenConnection(); * * InsertDAL insert = new InsertDAL(); * insert.OpenConnection(); * * foreach (AttendancePlanned p in get.GetAttendancePlannedByRehearsalPart(vm.CurrentRehearsalPart)) * { * foreach (AttendanceActual a in get.GetAttendanceActualByRehearsalPart(vm.CurrentRehearsalPart)) * { * if (a.AttendancePlanned.User.Equals(p.User) && vm.UsersCurrentlyAtRehearsal.Contains(p.User)) * { * a.DtmOutTime = DateTime.Now; * vm.UsersCurrentlyAtRehearsal.Remove(p.User); * vm.UsersNotCurrentlyAtRehearsal.Add(p.User); * insert.InsertAttendanceActual(a); * } * } * } * * insert.CloseConnection(); * get.CloseConnection(); * return RedirectToAction("Index", vm); * } */ /*public ActionResult FinishRehearsal(CheckInOutViewVM vm) * { * GetDAL get = new GetDAL(); * get.OpenConnection(); * * InsertDAL insert = new InsertDAL(); * insert.OpenConnection(); * * * foreach (AttendancePlanned p in get.GetAttendancePlannedByRehearsalPart(get.GetRehearsalPartByID(vm.CurrentRehearsalPart.IntRehearsalPartID))) * { * foreach (AttendanceActual a in get.GetAttendanceActualByPlanned(p)) * { * a.DtmOutTime = vm.CurrentRehearsalPart.DtmEndDateTime; * insert.InsertAttendanceActual(a); * } * } * * insert.CloseConnection(); * * get.CloseConnection(); * * return RedirectToAction("Index"); * } */ private List <Users> LstAllMembersForRehearsalParts(Event e, GetDAL connection) { List <Users> retval = new List <Users>(); // go through each rehearsal part's list of members List <RehearsalPart> today = e.LstRehearsalParts.Where(x => x.DtmStartDateTime.GetValueOrDefault().Date.Equals(DateTime.Now.Date)).ToList(); foreach (RehearsalPart rp in today) { retval = retval.Concat(rp.LstMembers.Where(x => !retval.Any(y => y.Equals(x)))).ToList(); } foreach (Users m in retval) { m.TimeScheduled = connection.GetFirstTimeByDayAndUser(DateTime.Now.Date, m); } return(retval); }
/* Takes the entered user and verifies if that is a * valid user in the database by checking its entered * username and password against the username and hashed * key store in the database. If the username and hashed * password match what is stored in the databse, then * a boolean value of true is returned; otherwise, * this function returns false. * * @param users user to be checked * * @return true if the user is verified to be * a valid user, false otherwise. */ public static bool VerifyUser(Users users) { // open a database connection GetDAL getDAL = new GetDAL(); getDAL.OpenConnection(); // find entered username in the databased Users usr = getDAL.GetUserByName(users.StrName); // close the database connection getDAL.CloseConnection(); // if username is found if (usr != null) { // get the stored key and salt for the user byte[] userSalt = usr.BytSalt; byte[] userKey = usr.BytKey; byte[] actual; try { /* compute a hashed key with the user's stored * salt and entered password */ actual = ComputeSHA256Hash(users.StrPassword, userSalt); } catch (ArgumentNullException) { /* catch an ArgumentNullException triggered by * blank password */ return(false); } /* if the computed hashed key matches what is stored * in the database then return login status */ if (StructuralComparisons.StructuralEqualityComparer.Equals(userKey, actual)) { return(LoginUser(usr)); } } // did not find username return(false); }
public ActionResult AddUserToEvent(ProfileHomeVM vm) { Users currentUser = Globals.LOGGED_IN_USER; // add user to group InsertDAL insertDAL = new InsertDAL(); insertDAL.OpenConnection(); insertDAL.InsertToUserEvents(vm.NewEvent, currentUser); insertDAL.CloseConnection(); GetDAL get = new GetDAL(); get.OpenConnection(); Globals.LOGGED_IN_USER.LstEvents = get.GetEventsByUser(currentUser.IntUserID); get.CloseConnection(); return(RedirectToAction("Index")); }
private static bool LoginUser(Users usr) { GetDAL getDAL = new GetDAL(); getDAL.OpenConnection(); usr.LstEvents = getDAL.GetEventsByUser(usr.IntUserID); usr.LstEventsIsAdmin = getDAL.GetAdminEventsByUser(usr.IntUserID); Globals.LOGIN_STATUS = true; Globals.LOGGED_IN_USER = usr; if (Globals.ADMINS.Contains(usr)) { Globals.IS_ADMIN = true; } getDAL.CloseConnection(); return(true); }
// GET: Conflict public ActionResult Index() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { ConflictsHomeVM model = new ConflictsHomeVM(); model.CurrentUser = Globals.LOGGED_IN_USER; GetDAL get = new GetDAL(); get.OpenConnection(); model.LstConflicts = get.GetConflictsByUser(model.CurrentUser); get.CloseConnection(); return(View("ConflictsHome", model)); } }
private List <RehearsalPart> ScheduleDay(DateTime start, Duration length, GetDAL get) { List <RehearsalPart> retval = new List <RehearsalPart>(); //DateTime end = start.AddMinutes(length.TotalMinutes); Duration totalRehearsalTimeForDay = Duration.Zero; DateTime rehearsalPartStart = start; DateTime rehearsalPartEnd = rehearsalPartStart; foreach (RehearsalPart rp in UnscheduledRehearsalParts.ToArray()) { double minutesRehearsalPartLength = rp.DurLength.ToDuration().TotalMinutes; rehearsalPartEnd = rehearsalPartEnd.AddMinutes(minutesRehearsalPartLength); // if the list of needed members do not have conflicts between start and end // AND the duration of the rehearsal part plus total time so far is less than the max length of the rehearsal bool hasConflicts = HasConflicts(rp.LstMembers, rehearsalPartStart, rehearsalPartEnd, get); bool rehearsalLengthFits = rp.DurLength.ToDuration().Plus(totalRehearsalTimeForDay) <= length; if (!hasConflicts && rehearsalLengthFits) { // start rehearsal part at given time rp.DtmStartDateTime = rehearsalPartStart; // end rehearsal part at given time rp.DtmEndDateTime = rehearsalPartStart.AddMinutes(minutesRehearsalPartLength); // move new rehearsal part start time to end rehearsalPartStart = (DateTime)rp.DtmEndDateTime; // reset rehearsal part end time to new start time rehearsalPartEnd = rehearsalPartStart; // add to total rehearsal time for day totalRehearsalTimeForDay = totalRehearsalTimeForDay.Plus(Duration.FromMinutes(minutesRehearsalPartLength)); // remove from unschedule rehearsal parts list UnscheduledRehearsalParts.Remove(rp); // add this rehearsal part to the list of scheduled parts retval.Add(rp); } } return(retval); }
// GET: Tasks public ActionResult Index() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { TasksHomeVM model = new TasksHomeVM(); model.CurrentUser = Globals.LOGGED_IN_USER; var taskEqualityComparer = new TaskEqualityComparer(); GetDAL get = new GetDAL(); get.OpenConnection(); model.TasksUnfinishedNotYetDueForUser = get.GetUnfinishedTasksDueAfter(model.CurrentUser, DateTime.Now); model.FinishedTasks = get.GetFinishedTasks(model.CurrentUser); IEnumerable <Task> difference = get.GetTasksByAssignedToUser(model.CurrentUser).Except(model.TasksUnfinishedNotYetDueForUser, taskEqualityComparer).Except(model.FinishedTasks, taskEqualityComparer); model.TasksOverDueForUser = difference.ToList(); model.TasksAssignedByUser = get.GetTasksByAssignedByUser(model.CurrentUser); model.LstAllEvents = get.GetAllEvents(); model.LstAdminEvents = get.GetAdminEventsByUser(model.CurrentUser.IntUserID); if (model.LstAdminEvents.Any()) { model.LstAllUsersForAdminEvents = get.GetAllUsersForAdminEvents(model.LstAdminEvents); } get.CloseConnection(); return(View("TasksHome", model)); } }
public FinalSchedule CreateSchedule(DateTime startDate, DateTime eventDate, GetDAL get) { // starting at the rehearsal start date List <DateTime> rehearsalDates = Enumerable.Range(0, 1 + eventDate.Subtract(startDate).Days) .Select(offset => startDate.AddDays(offset)) .ToList(); List <RehearsalPart> scheduledRehearsalParts = new List <RehearsalPart>(); foreach (var day in rehearsalDates) { if (UnscheduledRehearsalParts.Any()) { switch (day.DayOfWeek) { case DayOfWeek.Monday: DateTime monday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeMondayStart.Hour, EventSchedule.TmeMondayStart.Minute, EventSchedule.TmeMondayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(monday, EventSchedule.PerWeekdayDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Tuesday: DateTime tuesday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeTuesdayStart.Hour, EventSchedule.TmeTuesdayStart.Minute, EventSchedule.TmeTuesdayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(tuesday, EventSchedule.PerWeekdayDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Wednesday: DateTime wednesday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeWednesdayStart.Hour, EventSchedule.TmeWednesdayStart.Minute, EventSchedule.TmeWednesdayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(wednesday, EventSchedule.PerWeekdayDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Thursday: DateTime thursday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeThursdayStart.Hour, EventSchedule.TmeThursdayStart.Minute, EventSchedule.TmeThursdayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(thursday, EventSchedule.PerWeekdayDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Friday: DateTime friday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeFridayStart.Hour, EventSchedule.TmeFridayStart.Minute, EventSchedule.TmeFridayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(friday, EventSchedule.PerWeekdayDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Saturday: DateTime saturday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeSaturdayStart.Hour, EventSchedule.TmeSaturdayStart.Minute, EventSchedule.TmeSaturdayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(saturday, EventSchedule.PerWeekendDuration.ToDuration(), get)).ToList(); break; case DayOfWeek.Sunday: DateTime sunday = new DateTime(day.Year, day.Month, day.Day, EventSchedule.TmeSundayStart.Hour, EventSchedule.TmeSundayStart.Minute, EventSchedule.TmeSundayStart.Second); scheduledRehearsalParts = scheduledRehearsalParts.Concat(ScheduleDay(sunday, EventSchedule.PerWeekendDuration.ToDuration(), get)).ToList(); break; } } } FinalSchedule = new FinalSchedule(scheduledRehearsalParts, UnscheduledRehearsalParts); get.CloseConnection(); return(FinalSchedule); }
/// <summary> /// Returns true if at least one of the users has a conflict. Returns false if none of the users have a conflict for the given time /// </summary> /// <param name="LstMembers">List of members needed at that rehearsal</param> /// <param name="start">start time of rehearsal part</param> /// <param name="end">end time of rehearsal part</param> /// <returns>True if at least one of the users has a conflict</returns> private bool HasConflicts(List <Users> LstMembers, DateTime start, DateTime end, GetDAL get) { get.CloseConnection(); get.OpenConnection(); foreach (Users m in LstMembers) { List <Conflict> conflicts = get.GetConflictsByUserAndDay(m, new LocalDate(start.Year, start.Month, start.Day)); // as soon as we find someone with a conflict, return true:/ if ((conflicts.Exists(c => c.DtmEndDateTime > start) && conflicts.Exists(c => c.DtmStartDateTime < end)) || (conflicts.Exists(c => c.DtmStartDateTime < end) && conflicts.Exists(c => c.DtmEndDateTime > start))) { return(true); } } return(false); }
public ActionResult Dashboard() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login")); } else { DashboardVM model = new DashboardVM(); model.CurrentUser = Globals.LOGGED_IN_USER; model.LstEvents = model.CurrentUser.LstEvents; GetDAL get = new GetDAL(); get.OpenConnection(); var taskEqualityComparer = new TaskEqualityComparer(); // upcoming tasks should be all tasks due before two days from now EXCEPT ones already completed EXCEPT ones overdue // orrrr upcoming tasks should be all unfinished tasks due after today EXCEPT all tasks due after two days from now model.LstUpcomingTasks = get.GetUnfinishedTasksDueAfter(model.CurrentUser, DateTime.Now).Except(get.GetUnfinishedTasksDueAfter(model.CurrentUser, DateTime.Now.AddDays(DAYS_TO_SHOW_TASKS)), taskEqualityComparer).ToList(); // overdue tasks should be all tasks that are unfinished that are due before today model.LstOverdueTasks = get.GetUnfinishedTasksDueBefore(model.CurrentUser, DateTime.Now); /****************************** upcoming rehearsals stuff start *********/ get.CloseConnection(); get.OpenConnection(); // get LstUpcomingRehearsals model.LstUpcomingRehearsals = get.GetUpcomingRehearsalsByUser(Globals.LOGGED_IN_USER); foreach (var r in model.LstUpcomingRehearsals) { r.LstRehearsalParts = get.GetRehearsalPartsByRehearsal(r); foreach (RehearsalPart rp in r.LstRehearsalParts) { rp.LstMembers = get.GetUsersByRehearsalPart(rp); } r.LstRehearsalParts = r.LstRehearsalParts.Where(x => x.LstMembers.Contains(Globals.LOGGED_IN_USER)).ToList(); } model.LstUpcomingRehearsals = model.LstUpcomingRehearsals.Where(x => x.DtmStartDateTime <= DateTime.Now.AddDays(7)).ToList(); //get.CloseConnection(); //get.OpenConnection(); //// get members in each rehearsal //foreach (RehearsalPart rp in model.LstUpcomingRehearsalParts) //{ // rp.LstMembers = get.GetUsersByRehearsalPart(rp); //} //foreach (var e in get.GetEventsByUser(Globals.LOGGED_IN_USER.IntUserID)) //{ // get.CloseConnection(); // get.OpenConnection(); // model.LstUserRehearsalParts = model.LstUserRehearsalParts.Concat(get.GetRehearsalPartsByEvent(e)).ToList(); //} //get.CloseConnection(); //get.OpenConnection(); //model.LstUpcomingRehearsalParts = get.GetUpcomingRehearsalPartsByUser(Globals.LOGGED_IN_USER); //model.LstUnscheduledRehearsalParts = model.LstUserRehearsalParts.Where(x => x.DtmStartDateTime.Equals(null)).ToList(); //model.LstUpcomingRehearsalParts = model.LstUpcomingRehearsalParts.Except(model.LstUnscheduledRehearsalParts.ToList()).ToList(); //foreach (var r in model.LstUpcomingRehearsals) //{ // r.LstRehearsalParts = get.GetRehearsalPartsByRehearsal(r); //} //get.CloseConnection(); //get.OpenConnection(); //foreach (RehearsalPart rp in model.LstUpcomingRehearsalParts) //{ // rp.LstMembers = get.GetUsersByRehearsalPart(rp); //} //get.CloseConnection(); /****************************** upcoming rehearsals stuff end *********/ //foreach (Event e in model.LstEvents) //{ // List<Rehearsal> rehearsals = get.GetRehearsalsByEvent(e); // if (rehearsals.Any()) // { // model.LstUpcomingRehearsals = rehearsals; // } //} get.CloseConnection(); return(View("Dashboard", model)); } }
public frmShow(byte cn) { InitializeComponent(); getData = new GetDAL(); chucnangs = (chucNang)cn; }