/// <summary> /// Adds the update. /// </summary> /// <param name="holidayId">The holiday id.</param> /// <param name="subject">The subject.</param> /// <param name="date">The date.</param> /// <param name="description">The description.</param> /// <param name="countryId">The country identifier.</param> /// <returns> /// Add Update page /// </returns> public ActionResult ValidateHolidayDetails(string holidayId, string subject, string date, string description, string countryId) { ManageHolidaysPresenter presenter = new ManageHolidaysPresenter(); if (holidayId != null) { if (string.IsNullOrEmpty(subject.Trim())) { presenter.ValidationErrors.Add(Subject, Resources.SubjectErrorMessage); } DateTime dt; if (string.IsNullOrEmpty(date)) { presenter.ValidationErrors.Add(Date, Resources.DateErrorMessage); } else if (DateTime.TryParse(date, out dt)) { dt = Convert.ToDateTime(date); if (dt.Date < DateTime.Now.Date) { presenter.ValidationErrors.Add(Date, Resources.BackDateErrorMessage); } } else { presenter.ValidationErrors.Add(Date, Resources.DateErrorMessage); } if (string.IsNullOrEmpty(description.Trim())) { presenter.ValidationErrors.Add(Description, Resources.DescriptionErrorMessage); } if (string.IsNullOrEmpty(countryId)) { presenter.ValidationErrors.Add(Country, Resources.CountryErrorMessage); } } return new JsonResult { Data = presenter, MaxJsonLength = int.MaxValue }; }
/// <summary> /// Adds the update. /// </summary> /// <param name="holidayId">The holiday id.</param> /// <param name="subject">The subject.</param> /// <param name="date">The date.</param> /// <param name="description">The description.</param> /// <param name="countryId">The country identifier.</param> /// <returns> /// Add Update page /// </returns> public ActionResult SaveHolidayDetails(string holidayId, string subject, string date, string description, string countryId) { ManageHolidaysPresenter presenter = new ManageHolidaysPresenter(); if (!string.IsNullOrWhiteSpace(holidayId)) { presenter.Holiday.HolidayID = Convert.ToInt32(holidayId); } presenter.Holiday.Date = Convert.ToDateTime(date); presenter.Holiday.Subject = subject; presenter.Holiday.Remarks = description; presenter.Holiday.CountryID = Convert.ToInt32(countryId); presenter.Holiday.ModifiedByDeveloperID = SessionData.Instance.UserInfo.Developer.DeveloperID; presenter.Holiday.ModifiedDate = DateTime.Now; ErrorListItem error = this.holidayService.Validate(presenter.Holiday, SessionData.Instance.UserInfo.Developer.DeveloperID); if (error != null) { return this.Json(error.Message); } this.holidayService.InsertOrUpdate(presenter.Holiday); return null; }
/// <summary> /// Function to retrieve manage holiday page. /// </summary> /// <param name="countryId">The country Id.</param> /// <param name="year">The year Id.</param> /// <returns>Manage Holiday page</returns> public ActionResult ManageHolidays(string countryId, string year) { ManageHolidaysPresenter presenter = new ManageHolidaysPresenter(); presenter.SelectedCountry = !string.IsNullOrEmpty(countryId) ? Convert.ToInt32(countryId) : 1; presenter.SelectedYear = !string.IsNullOrEmpty(year) ? Convert.ToInt32(year) : DateTime.Now.Year; this.AddBreadcrumbItem(Resources.Masters, Url.MasterAction()); this.AddBreadcrumbItem(Resources.ManageHolidays, Url.MasterHolidayAction()); presenter.AssignCountryList(this.lookupService.RetrieveCountryList(SessionData.Instance.UserInfo.Developer.DeveloperID)); return this.View(presenter); }