public ActionResult FullCustom(FullCustomForm fullCustomForm) { var fullCustomFormTimeLogConverter = new FullCustomFormTimeLogConverter(clock); var timeLog = fullCustomFormTimeLogConverter.Convert(fullCustomForm); timeLog.UserId = Principal.Id; DocumentSession.Store(timeLog); TempData["prev-date"] = fullCustomForm.Date; return RedirectToAction("Index"); }
public TimeLog Convert(FullCustomForm form) { var timeLog = new TimeLog(); if (form.StartTime.Equals(new LocalTime())) { form.StartTime = clock.Now.InZone(dateTimeZone).LocalDateTime.TimeOfDay; } LocalDateTime startDateTime = (form.Date + form.StartTime); timeLog.StartTime = startDateTime.InZoneStrictly(dateTimeZone).ToDateTimeOffset(); Duration between = Period.Between(form.StartTime, form.EndTime).ToDuration(); if (between > Duration.Zero) { timeLog.Duration = between.ToTimeSpan(); } return timeLog; }