private void btnSave_Click(object sender, EventArgs e) { try { ClearStatus(); DateTime date = dtbDate.Text.Trim() != Constants.NULL_STRING ? DateTime.Parse(dtbDate.Text) : Constants.NULL_DATE; int blackoutDateID; if (blackoutDate == null) { scheduleController.CreateBlackoutDate(schedule, tbDescription.Text.Trim(), date, CurrentUser.Identity.Name); blackoutDateID = schedule.BlackoutDates.First(b => b.Date.Date == date.Date).BlackoutDateID; blackoutDate = schedule.BlackoutDates.SingleOrDefault(b => b.BlackoutDateID == blackoutDateID); } else { scheduleController.UpdateBlackoutDate(schedule, blackoutDate.BlackoutDateID, tbDescription.Text.Trim(), date, CurrentUser.Identity.Name); blackoutDateID = blackoutDate.BlackoutDateID; } ihBlackoutDateID.Value = blackoutDateID.ToString(); ShowSuccess(); } catch (ValidationException ex) { ShowErrors(ex.Errors); } }
public void Validation_Success() { BlackoutDate blackoutDate = TestFactories.GetBlackoutDate(); bool result = blackoutDate.IsValid; Assert.IsTrue(result); Assert.AreEqual(blackoutDate.Errors.Count, 0); }
public void CreateBlackoutDate(BlackoutDate blackoutDate, string userID) { blackoutDate.Update(userID); if (blackoutDate.IsValid) { Entity.BlackoutDates.Add(blackoutDate); scheduleRepository.Save(); } }
public void Blackout_Date_Read() { ScheduleController controller = new ScheduleController(); Schedule schedule = CreateSchedule(); controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user"); BlackoutDate blackoutDate = schedule.BlackoutDates.First(); string key = KeyHelper.GetKey <IBlackoutDateRepository>(); BlackoutDate newBlackoutDate = RepositoryFactory.GetRepository <IBlackoutDateRepository>(key).GetBlackoutDate(blackoutDate.BlackoutDateID); Assert.AreSame(blackoutDate, newBlackoutDate); }
public FakeBlackoutDateRepository() { if (blackoutDates.Count == 0) { for (int i = 0; i < 3; i++) { BlackoutDate blackoutDate = TestFactories.GetBlackoutDate(); blackoutDate.BlackoutDateID = i + 1; blackoutDates.Add(blackoutDate); count++; } } }
public void CreateBlackoutDate(Schedule schedule, string description, DateTime date, string userID) { BlackoutDate blackoutDate = new BlackoutDate { ScheduleID = schedule.ScheduleID, Description = description, Date = date }; var bll = GetCachedObject <ScheduleBll>(BLL_SESSION_PREFIX, schedule.ScheduleID); bll.CreateBlackoutDate(blackoutDate, userID); SaveObjectToCache(BLL_SESSION_PREFIX, schedule.ScheduleID, bll); }
public void Blackout_Date_Delete() { ScheduleController controller = new ScheduleController(); Schedule schedule = CreateSchedule(); controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user"); BlackoutDate blackoutDate = schedule.BlackoutDates.First(); int blackoutDateID = blackoutDate.BlackoutDateID; controller.DeleteBlackoutDate(schedule, blackoutDateID); string key = KeyHelper.GetKey <IBlackoutDateRepository>(); Assert.IsFalse(RepositoryFactory.GetRepository <IBlackoutDateRepository>(key).Exists(blackoutDateID)); }
public void Blackout_Date_Update() { ScheduleController controller = new ScheduleController(); Schedule schedule = CreateSchedule(); controller.CreateBlackoutDate(schedule, "Test blackout date", DateTime.Now, "test user"); BlackoutDate blackoutDate = schedule.BlackoutDates.First(); blackoutDate.Date = DateTime.Now.AddDays(1); controller.UpdateBlackoutDate(schedule, blackoutDate.BlackoutDateID, blackoutDate.Description, blackoutDate.Date, "other user"); Assert.AreNotEqual(blackoutDate.Date, DateTime.Now); Assert.AreNotEqual(blackoutDate.CreatedBy, blackoutDate.ModifiedBy); Assert.AreEqual(blackoutDate.ModifiedBy, "other user"); }
private void BuildBlackoutDate() { BlackoutDate blackoutDate = schedule.BlackoutDates.SingleOrDefault(b => b.Date.Date == calSchedule.SelectedDate.Date); if (blackoutDate != null) { phItems.Controls.Add(new LiteralControl("<div class=\"errors\">")); phItems.Controls.Add(new LiteralControl(string.Format("<h4 class=\"errorText\">{0} has been blacked out!</h4>", blackoutDate.Date.ToLongDateString()))); phItems.Controls.Add(new LiteralControl(string.Format("<span class=\"errorCaption\">"{0}"</span>", Server.HtmlEncode(blackoutDate.Description)))); LinkButton lbEdit = new LinkButton(); phItems.Controls.Add(lbEdit); lbEdit.ID = string.Format("lbEditBlackoutDate_{0}", blackoutDate.BlackoutDateID); lbEdit.Text = "Edit"; lbEdit.CssClass = "smallText edit-blackout"; lbEdit.Attributes.Add("onclick", GetJavaScriptRedirect(EditBlackoutDatePageSetting, "blackoutdate", blackoutDate.BlackoutDateID)); phItems.Controls.Add(new LiteralControl("</div>")); } }
public void Validation_Failure() { BlackoutDate blackoutDate = new BlackoutDate { Date = Constants.NULL_DATE, Description = Constants.NULL_STRING, ScheduleID = 0 }; try { bool result = blackoutDate.IsValid; Assert.Fail(string.Format("Validation should have failed, not returned '{0}'", result)); } catch (ValidationException ex) { Assert.AreEqual(ex.Errors.Count, 3); Assert.IsTrue(ex.Errors[0].Contains("Description")); Assert.IsTrue(ex.Errors[1].Contains("Date")); Assert.IsTrue(ex.Errors[2].Contains("Schedule")); } }
private void GetSchedule() { string scheduleID = Request.QueryString.Get("schedule"); string blackoutDateID = Request.QueryString.Get("blackoutdate"); if (scheduleID == null) { return; } schedule = scheduleController.GetSchedule(int.Parse(scheduleID)); if (blackoutDateID == null) { blackoutDateID = ihBlackoutDateID.Value.Trim() != Constants.NULL_STRING ? ihBlackoutDateID.Value : null; } if (blackoutDateID != null) { blackoutDate = schedule.BlackoutDates.SingleOrDefault(b => b.BlackoutDateID == int.Parse(blackoutDateID)); } }
public void Delete(BlackoutDate blackoutDate) { db.GetTable <BlackoutDate>().DeleteOnSubmit(blackoutDate); }
public void Delete(BlackoutDate date) { blackoutDates.Remove(date); }
public void AddBlackoutDate(BlackoutDate date) { count++; date.BlackoutDateID = count; blackoutDates.Add(date); }