public static DateTime EnsureDateTime(DateTime value, TimeZoneInfo timeZone, DateTimeHandling dateTimeHandling, UnspecifiedDateTimeHandling unspecifiedDateTimeHandling) { if (dateTimeHandling == DateTimeHandling.Utc) { if (timeZone == null) { return(SwitchToUtcTime(value, unspecifiedDateTimeHandling)); } return(SwitchToUtcTime(value, timeZone, unspecifiedDateTimeHandling)); } else if (dateTimeHandling == DateTimeHandling.Local) { if (timeZone == null) { return(SwitchToLocalTime(value, unspecifiedDateTimeHandling)); } return(SwitchToLocalTime(value, timeZone, unspecifiedDateTimeHandling)); } else if (dateTimeHandling == DateTimeHandling.Current) { if (value.Kind == DateTimeKind.Utc) { return(EnsureDateTime(value, timeZone, DateTimeHandling.Utc, unspecifiedDateTimeHandling)); } else if (value.Kind == DateTimeKind.Local) { return(EnsureDateTime(value, timeZone, DateTimeHandling.Local, unspecifiedDateTimeHandling)); } else { if (unspecifiedDateTimeHandling == UnspecifiedDateTimeHandling.AssumeUtc) { return(EnsureDateTime(value, timeZone, DateTimeHandling.Utc, unspecifiedDateTimeHandling)); } else if (unspecifiedDateTimeHandling == UnspecifiedDateTimeHandling.AssumeLocal) { return(EnsureDateTime(value, timeZone, DateTimeHandling.Local, unspecifiedDateTimeHandling)); } else { ThrowUnsupportedOption(unspecifiedDateTimeHandling.ToString()); return(value); } } } else { ThrowUnsupportedOption(dateTimeHandling.ToString()); return(value); } }
public ActionResult AddTravelForm(TravelDetailViewModel travelDataVm, string start_date, string end_date) { TravelDetailModel travelData = travelDataVm.traveldetail; travelData.UserID = CurrentUserDetail().ID; try { //travelDataVm.traveldetail.Detail_DepartingDate = DateTime.ParseExact(start_date, "MM/dd/yyyy", null); //travelDataVm.traveldetail.Detail_ReturningDate = DateTime.ParseExact(end_date, "MM/dd/yyyy", null); travelData.Detail_DepartingDate = DateTimeHandling.SetDateTime(travelData.Detail_DepartingDate); travelData.Detail_ReturningDate = DateTimeHandling.SetDateTime(travelData.Detail_ReturningDate); travelData.Summary_SubmittedDate = DateTimeHandling.SetDateTime(DateTime.Now); travelData.LastStatus = Convert.ToInt32(TravelRequestStatusEnum.SubmittedByUser);; if (travelData.Id != 0) { travelData.LastStatus = Convert.ToInt32(TravelRequestStatusEnum.Resubmitted); //travelDataVm.id= travelData.Id; objmanageTravel.UpdateTravelDetail(travelDataVm); } else { TravelDetailModel traveldata = objmanageTravel.InsertTraveldata(travelData); } if (travelData != null) { try { TempData.Add("TravelResult", "Travel Information Saved successfully"); } catch { TempData["TravelResult"] = "Travel Information Saved successfully"; } return(RedirectToAction("travellist")); } } catch (Exception ex) { throw ex; } return(RedirectToAction("addtravelform")); }
public ActionResult TravelList(string UserTimezoneOffSet) { List <TravelDetailModel> TravelList = objProjectManager.GetAllTravelDetail().Where(x => x.Detail_DepartingDate.Month == DateTime.UtcNow.Month).ToList(); List <Calendar_EventsVM> EventList = new List <Calendar_EventsVM>(); foreach (var item in TravelList) { DateTime startdate = DateTimeHandling.GetDateTime(item.Detail_DepartingDate); DateTime enddate = DateTimeHandling.GetDateTime(item.Detail_ReturningDate); Calendar_EventsVM cal = new Calendar_EventsVM(); cal.id = item.Id; cal.start = startdate.ToString(); //item.Detail_DepartingDate.ToString("MM/dd/yyyy"); cal.end = enddate.ToString(); //item.Detail_ReturningDate.ToString("MM/dd/yyyy"); cal.title = item.Summary_TravelerName + "\n " + startdate.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) + " - " + enddate.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) + "\n " + item.Summary_ProjectName; cal.desc = item.Summary_TravelerName; cal.status = item.LastStatus.ToString(); string colour = ""; string statusCss = string.Empty; switch (item.LastStatus) { case (int)TravelRequestStatusEnum.SubmittedByUser: colour = "#63c2de"; statusCss = "cal-blue blue"; break; case (int)TravelRequestStatusEnum.Resubmitted: colour = "#6b73e7"; statusCss = "cal-blue-dark dark-blue"; break; case (int)TravelRequestStatusEnum.InProcess: case (int)TravelRequestStatusEnum.ApprovedByProjectManager: case (int)TravelRequestStatusEnum.ApprovedByClient1: colour = "#f8cb00"; statusCss = "cal-yellow yellow"; break; case (int)TravelRequestStatusEnum.ApprovedByClient2: colour = "#45dcbd"; statusCss = "cal-green green"; break; case (int)TravelRequestStatusEnum.RejectedByClient1: case (int)TravelRequestStatusEnum.RejectedByClient2: case (int)TravelRequestStatusEnum.RejectedByProjectManager: colour = "#f96d6c"; statusCss = "cal-red red-cl"; break; } cal.className = statusCss; cal.color = colour; EventList.Add(cal); } //foreach (var item in EventList) //{ // DateTime dt = Convert.ToDateTime(item.start); // DateTime dtEnd = Convert.ToDateTime(item.end); // item.start = dt.ToString("yyyy-MM-dd") + "T10:30:00Z"; // item.end = dtEnd.ToString("yyyy-MM-dd") + "T10:30:00Z"; //} EventList.ForEach(x => { x.start = (Convert.ToDateTime(x.start).ToString("yyyy-MM-dd") + "T10:30:00Z"); x.end = (Convert.ToDateTime(x.end).ToString("yyyy-MM-dd") + "T10:30:00Z"); }); var TravelListJSONData = Json(EventList, JsonRequestBehavior.AllowGet); return(TravelListJSONData); }
public static DateTime EnsureDateTime(DateTime value, DateTimeHandling dateTimeHandling, UnspecifiedDateTimeHandling unspecifiedDateTimeHandling) { return(EnsureDateTime(value, null, dateTimeHandling, unspecifiedDateTimeHandling)); }
public DateTimeFieldsTransformation(DateTimeHandling handlingType) { this.handlingType = handlingType; }
public DateTimeFieldsTransformation(DateTimeHandling handlingType) { this.handlingType = handlingType; }