public ActionResult WorkLog(WorkLogViewModel model) { //string selectedDate = Request.QueryString["month"]; int year = DateTime.Now.Year; int month = DateTime.Now.Month; if (!string.IsNullOrWhiteSpace(model.Month)) { string[] arr = model.Month.Split("/".ToArray(), StringSplitOptions.RemoveEmptyEntries); int yearTemp, monthTemp; if (int.TryParse(arr[0], out monthTemp) && int.TryParse(arr[1], out yearTemp) && monthTemp > 0 && yearTemp > 1900) { year = yearTemp; month = monthTemp; } } if (CurrentUser.IsManager) { model = WorkLogService.GetAllUserWorkLogs(year, month, model.SortField, model.SortDirection, model.Filter); } else { model = WorkLogService.GetWorkLogs(CurrentUser.Id, year, month); } return(View(model)); }
public ActionResult WorkLog() { //DateTime startDate = DateTime.Now.Date; //DateTime endDate = DateTime.Now.Date; //if (Request.QueryString["startDate"] != null) // startDate = DateTime.ParseExact(Request.QueryString["startDate"].ToString(), "dd/MM/yyyy", // System.Globalization.CultureInfo.InvariantCulture); //if (Request.QueryString["endDate"] != null) // endDate = DateTime.ParseExact(Request.QueryString["endDate"].ToString(), "dd/MM/yyyy", // System.Globalization.CultureInfo.InvariantCulture); WorkLogViewModel vm = new WorkLogViewModel(); return(View(vm)); }
public ActionResult GetWorkLog() { DateTime startDate = DateTime.Now.Date; DateTime endDate = DateTime.Now.Date; if (Request.QueryString["startDate"] != null) { startDate = DateTime.ParseExact(Request.QueryString["startDate"].ToString(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); } if (Request.QueryString["endDate"] != null) { endDate = DateTime.ParseExact(Request.QueryString["endDate"].ToString(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); } WorkLogViewModel vm = new WorkLogViewModel(); var worklog = _context.tblWorkLogs.ToList(); worklog.Where(x => x.StartTime <= startDate || x.StartTime >= endDate) .ToList().ForEach(c => vm.WorkLogs.Add(new WorkLogModel() { WorkLogId = c.WorkLogId, StartTime = c.StartTime.Value.ToString("dd/MM/yyyy HH:mm"), EndTime = c.EndTime.Value.ToString("dd/MM/yyyy HH:mm"), Duration = (c.Duration / 60), TaskId = c.TaskId, Unit = c.Unit, AverageTime = c.AverageTime, TaskName = _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).TaskName, ProjectId = _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).ProjectId, ProjectName = _context.tblProjects.FirstOrDefault(v => v.ProjectId == _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).ProjectId).ProjectName })); var list = from s in vm.WorkLogs select s; var json = Json(new { data = list.ToList() }, JsonRequestBehavior.AllowGet); return(json); }
public ActionResult Index() { WorkLogViewModel vm = new WorkLogViewModel(); _context.tblWorkLogs.ToList().ForEach(c => vm.WorkLogs.Add(new WorkLogModel() { WorkLogId = c.WorkLogId, StartTime = c.StartTime.Value.ToString("dd/MM/yyyy HH:mm"), EndTime = c.EndTime.Value.ToString("dd/MM/yyyy HH:mm"), Duration = (c.Duration / 60), TaskId = c.TaskId, Unit = c.Unit, AverageTime = c.AverageTime, TaskName = _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).TaskName, ProjectId = _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).ProjectId, ProjectName = _context.tblProjects.FirstOrDefault(v => v.ProjectId == _context.tblTasks.FirstOrDefault(x => x.TaskId == c.TaskId).ProjectId).ProjectName })); return(View(vm)); }