public async Task <TimeLogViewModel> IsBilledUpdate(TimeLogViewModel viewModel) { List <Expression <Func <TimeLog, bool> > > filterPredicates = new List <Expression <Func <TimeLog, bool> > >(); filterPredicates.Add(p => p.IsActive == true); filterPredicates.Add(p => p.ClaimId == viewModel.ClaimId); filterPredicates.Add(p => p.TimeLogId == viewModel.TimeLogId); //return EntityToViewModelMapper.Map(this.TimeLogRepository.Find(filterPredicates).ToList()); // EntityToViewModelMapper.Map(this.TimeLogRepository.Find(filterPredicates)); var timelog = this.TimeLogRepository.Find(filterPredicates).FirstOrDefault(); if (timelog != null) { var lastModifiedDate = timelog.LastModifiedOn; timelog = this.TimeLogRepository.Update(ViewModelToEntityMapper.IsBilledMap(viewModel, timelog)); if (lastModifiedDate < timelog.LastModifiedOn) { return(viewModel); } else { viewModel.HasError = true; } } return(viewModel); }
public IActionResult Index(TimeLogViewModel vm) { if (ModelState.IsValid) { // Get the maximum PK in Log int maxLogId = 0; if (_context.Log.Any()) { maxLogId = _context.Log.Max(t => t.LogId); } // Get the maximum PK in UserLog int userLogMaxId = 0; if (_context.UserLog.Any()) { userLogMaxId = _context.UserLog.Max(t => t.UserLogId); } // The date selected by the user (goes in Log) DateTime enteredDate = DateTime.Parse(vm.date); // Write the Log record Log Log = new Log { Date = enteredDate, TimeInId = vm.TimeInID }; _context.Add(Log); _context.SaveChanges(); int tempLogId = 0; tempLogId = (maxLogId + 1); int count = (vm.SelectedIDArray).Count; UserLog[] tempULog = new UserLog[count]; string[] userkeys = new string[count]; userkeys = (vm.SelectedIDArray).ToArray(); for (int i = 0; i < ((vm.SelectedIDArray).Count); i++) { userLogMaxId += 1; tempULog[i] = TimeLogSupport.createUserLogRecord(tempLogId, userkeys[i], userLogMaxId); _context.Add(tempULog[i]); } _context.SaveChanges(); return(RedirectToAction("ShowLog", vm)); } return(View()); }
public IActionResult DisplayLog(TimeLogViewModel vm) { DateTime tempDate = DateTime.Parse(vm.date); ViewBag.TheDate = tempDate; TimeLogSupport timeLogSupport = new TimeLogSupport(_context); return(RedirectToAction("ShowLog", vm)); }
public IActionResult ShowLog(DateTime date, TimeLogViewModel vm) { TimeLogSupport timeLogSupport = new TimeLogSupport(_context); string dt = date.ToString("yyyy/MM/dd"); ViewBag.TheDate = dt; ViewBag.TheCategory = timeLogSupport.getTimeInCategory(vm.TimeInID); return(View(timeLogSupport.getUserName(vm))); }
public void AddTimeLog(TimeLogViewModel timeLogViewModel, long taskId) { var timeLog = new TimeLog { StartTime = timeLogViewModel.StartTime, EndTime = timeLogViewModel.EndTime, TaskId = taskId, }; db.TimeLogs.Add(timeLog); db.SaveChanges(); }
public static TimeLog IsBilledMap(TimeLogViewModel viewModel, TimeLog entity) { if (viewModel == null || entity == null) { return(null); } entity.LastModifiedBy = viewModel.LastModifiedBy; entity.LastModifiedOn = DateTime.Now; entity.IsBilled = viewModel.IsBilled; return(entity); }
public async Task <TimeLogViewModel> Find(int timeLogId) { try { TimeLogViewModel timeLog = await this.BusinessLayer.Find(timeLogId); return(timeLog); } catch (Exception ex) { this.ExceptionLogger.Log(LogLevel.Error, ex); throw ex; } }
// Returns a List<User> containing all the records returned from the select query public List <User> getUserName(TimeLogViewModel vm) { List <User> showLVM = new List <User>(); DateTime date = DateTime.Parse(vm.date); showLVM = (from l in _context.Log join c in _context.UserLog on l.LogId equals c.LogId join u in _context.User on c.UserId equals u.UserId where c.UserId == u.UserId && l.TimeInId == vm.TimeInID && l.Date == date select u).ToList(); return(showLVM); }
public static void SubmitTimeLog(TimeLogViewModel log) { var timeLoggingContext = new TimeLoggingContext(); var newEntry = new Log() { Billable = log.Billable, Comment = log.Comment, EndTime = log.EndTime, StartTime = log.StartTime, UserId = "doug" }; timeLoggingContext.Logs.Add(newEntry); timeLoggingContext.SaveChanges(); }
public async Task <TimeLogViewModel> Create(TimeLogViewModel viewModel) { var timelog = this.TimeLogRepository.Add(ViewModelToEntityMapper.Map(viewModel)); if (timelog.TimeLogId > 0) { viewModel.TimeLogId = timelog.TimeLogId; } else { viewModel.HasError = true; } return(viewModel); }
public async Task <TimeLogViewModel> Update(TimeLogViewModel viewModel) { try { viewModel.LastModifiedBy = User.Identity.GetUserId(); viewModel.LastModifiedOn = DateTime.Now; viewModel.IsActive = true; TimeLogViewModel timeLog = await this.BusinessLayer.Update(viewModel); return(timeLog); } catch (Exception ex) { this.ExceptionLogger.Log(LogLevel.Error, ex); throw ex; } }
public async Task <TimeLogViewModel> Update(TimeLogViewModel viewModel) { var timelog = this.TimeLogRepository.Find(viewModel.TimeLogId); if (timelog != null && timelog.IsActive) { var lastModifiedDate = timelog.LastModifiedOn; timelog = this.TimeLogRepository.Update(ViewModelToEntityMapper.Map(viewModel, timelog)); if (lastModifiedDate < timelog.LastModifiedOn) { return(viewModel); } else { viewModel.HasError = true; } } return(viewModel); }
public static TimeLog Map(TimeLogViewModel viewModel, TimeLog entity) { if (viewModel == null || entity == null) { return(null); } entity.ClaimId = viewModel.ClaimId; entity.ServiceItemId = viewModel.ServiceItemId; entity.Quantity = viewModel.Quantity; entity.HoursSpent = viewModel.HoursSpent; entity.Comment = viewModel.Comment; entity.TaskDate = !string.IsNullOrWhiteSpace(viewModel.TaskDate) ? DateTime.ParseExact(viewModel.TaskDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now.Date; entity.LoggedOn = !string.IsNullOrWhiteSpace(viewModel.LoggedOn) ? DateTime.ParseExact(viewModel.LoggedOn, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now.Date; entity.AdjusterId = viewModel.Adjuster != null ? viewModel.Adjuster.UserId : null; entity.LastModifiedBy = viewModel.LastModifiedBy; entity.LastModifiedOn = viewModel.LastModifiedOn; entity.IsActive = viewModel.IsActive; return(entity); }
public static TimeLog Map(TimeLogViewModel viewModel) { if (viewModel == null) { return(null); } return(new TimeLog { ClaimId = viewModel.ClaimId, ServiceItemId = viewModel.ServiceItemId, Quantity = viewModel.Quantity, HoursSpent = viewModel.HoursSpent, Comment = viewModel.Comment, TaskDate = !string.IsNullOrWhiteSpace(viewModel.TaskDate) ? DateTime.ParseExact(viewModel.TaskDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now, LoggedOn = !string.IsNullOrWhiteSpace(viewModel.LoggedOn) ? DateTime.ParseExact(viewModel.LoggedOn, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now, AdjusterId = viewModel.Adjuster != null ? viewModel.Adjuster.UserId : null, CreatedBy = viewModel.CreatedBy, CreatedOn = viewModel.CreatedOn, LastModifiedBy = viewModel.LastModifiedBy, LastModifiedOn = viewModel.LastModifiedOn, IsActive = viewModel.IsActive }); }
public ActionResult SubmitTimeLog(TimeLogViewModel log) { TimeLogService.SubmitTimeLog(log); return(RedirectToAction("Index", "Home")); }