public override void ViewDidLoad() { base.ViewDidLoad(); _timesheet = Hub.GetEx <TimesheetResource> ("timesheet"); _vm = new TimesheetViewModel(); _vm.InitialiseWith(_timesheet); }
/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <returns>IActionResult.</returns> public async Task <IActionResult> Edit(int?id) { TimesheetViewModel model = new TimesheetViewModel(); if (id == null) { return(NotFound()); } var timesheet = await _context.Timesheet.FindAsync(id); if (id != null) { model.EmpID = timesheet.EmpID; model.PunchIn = timesheet.PunchIn; model.PunchOut = timesheet.PunchOut; model.TotalWorkTime = timesheet.TotalWorkTime; model.TotalPay = timesheet.TotalPay; } if (timesheet == null) { return(NotFound()); } ViewData["EmpID"] = new SelectList(_context.Employee, "Id", "FULL_NAME", model.EmpID); return(View(timesheet)); }
/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <returns>IActionResult.</returns> public async Task <IActionResult> Edit(int?id) { TimesheetViewModel model = new TimesheetViewModel(); if (id == null) { return(NotFound()); } var timesheet = await _context.Timesheet.FindAsync(id); if (id != null) { model.EmpID = timesheet.EmpID; model.PunchIn = timesheet.PunchIn; model.PunchOut = timesheet.PunchOut; model.TotalWorkTime = timesheet.TotalWorkTime; model.TotalPay = timesheet.TotalPay; } if (timesheet == null) { return(NotFound()); } return(View(timesheet)); }
public JsonResult PostDate(int hour, int minute, int seconds, string comment) { var clockOutDate = DateTime.Now; var clockInDate = DateTime.Now.Add(new TimeSpan(-hour, -minute, -seconds)); if (hour >= 8) { clockOutDate = clockInDate.Add(new TimeSpan(8, 0, 0)); } var timesheet = new Timesheet(); timesheet.ClockInTime = clockInDate; timesheet.ClockOutTime = clockOutDate; timesheet.Comment = comment; timesheet.UserId = User.Identity.GetUserId(); _unitOfWork.Timesheets.Add(timesheet); _unitOfWork.Complete(); var clockedInTimeSpan = new TimeSpan(); foreach (var ts in _unitOfWork.Timesheets.GetAll().Where(x => x.ClockInTime.Day == DateTime.Now.Day && x.ClockOutTime.Day == DateTime.Now.Day)) { TimeSpan timeSpan = new TimeSpan(); timeSpan = (ts.ClockOutTime - ts.ClockInTime); clockedInTimeSpan = timeSpan + clockedInTimeSpan; } var timesheetViewModel = new TimesheetViewModel { ClockedInTimeSpan = clockedInTimeSpan, Timesheet = timesheet }; return(Json(timesheetViewModel)); }
public async Task <IActionResult> PutTimesheet(int id, TimesheetViewModel timesheet) { if (timesheet.Id != id) { throw new Exception(string.Format("Id không giống nhau!")); } try { await Task.Run(() => { timesheet.DateModified = DateTime.Now; _timesheetService.Update(timesheet); _timesheetService.SaveChanges(); return(Ok("Cập nhập thành công!")); }); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public JsonResult RejectTimesheet(TimesheetViewModel model) { string userName = this.membershipService.GetCurrentUserName(); model.TimesheetChecker = userName; return(Json(timesheetService.RejectTimesheet(model), JsonRequestBehavior.AllowGet)); }
public async Task <TimesheetViewModel> GetEditViewModel(Activity activity) { var groups = await GetGroups(); var types = await GetTypes(); var TimesheetViewModel = new TimesheetViewModel { Id = activity.Id, ActivityGroupId = activity.ActivityGroupId, Date = activity.Date, Duration = activity.Duration, DurationType = activity.DurationType, Info = activity.Info, ActivityTypeId = activity.ActivityTypeId, Frequency = activity.Frequency, CreatedAt = activity.CreatedAt, CreatedBy = activity.CreatedBy, UpdatedAt = activity.UpdatedAt, UpdatedBy = activity.UpdatedBy, GroupSelectItem = groups.Select(x => new SelectListItem { Value = $"{x.Id}", Text = x.Name, Selected = x.Id == activity.ActivityGroupId }).ToList(), TypeSelectItem = types.Select(x => new SelectListItem { Value = $"{x.Id}", Text = x.Name, Selected = x.Id == activity.ActivityTypeId }).ToList() }; return(TimesheetViewModel); }
public async Task <IActionResult> Edit(int id, [Bind("PunchIn,PunchOut,Status,EmpID,TotalWorkTime,Id,TimeStamp")] TimesheetViewModel timesheet) { if (ModelState.IsValid) { var timesheetEdit = await _context.Timesheet.FindAsync(id); if (timesheetEdit != null) { timesheetEdit.PunchIn = timesheet.PunchIn; timesheetEdit.PunchOut = timesheet.PunchOut; timesheetEdit.EmpID = timesheet.EmpID; if (timesheetEdit.PunchOut != null) { DateTime ValidPunchOut = timesheet.PunchOut.Value; TimeSpan difference = ValidPunchOut - timesheetEdit.PunchIn; timesheet.TotalWorkTime = string.Format("{0:0}:{1:00}", difference.TotalHours, difference.Minutes); } else { } } _context.Update(timesheetEdit); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmpID"] = new SelectList(_context.Employee, "Id", "FULL_NAME", timesheet.EmpID); return(View(timesheet)); }
public bool Add(TimesheetViewModel timesheetVm) { try { var timeSheet = Mapper.Map <TimesheetViewModel, Timesheet>(timesheetVm); _timesheetRepository.Add(timeSheet); return(true); } catch { return(false); } }
public Task DisplayViewerFor <TResource>(TResource resource) { if (resource is TimesheetResource) { var vm = new TimesheetViewModel(); vm.InitialiseWith(resource as TimesheetResource); Hub.PutEx(typeof(EditTimesheetActivity), vm); _context.StartActivity(typeof(EditTimesheetActivity)); } var t = new TaskCompletionSource <object>(); t.SetResult(null); return(t.Task); }
public void Should_not_set_value() { var source = new TimesheetModel { Contact = 6, ContactNavigation = new ContactModel { Id = 5 } }; var dest = new TimesheetViewModel { Contact = 10 }; Mapper.Map(dest, source); source.ContactNavigation.Id.ShouldBe(5); }
public bool UpdateTamUng(TimesheetViewModel timesheetVm, decimal tientamung) { try { timesheetVm.AdvancePayment = timesheetVm.AdvancePayment + tientamung; timesheetVm.TotalActualSalary = timesheetVm.SalaryOfDay * Convert.ToDecimal(timesheetVm.TotalWorkday) + timesheetVm.Allowance + timesheetVm.Bonus - timesheetVm.AdvancePayment - timesheetVm.InsurancePremiums; var timeSheet = Mapper.Map <TimesheetViewModel, Timesheet>(timesheetVm); _timesheetRepository.Update(timeSheet); return(true); } catch { return(false); } }
public async Task <TimesheetViewModel> GetCreateViewModel() { var groups = await GetGroups(); var types = await GetTypes(); var TimesheetViewModel = new TimesheetViewModel { GroupSelectItem = groups.Select(x => new SelectListItem { Value = $"{x.Id}", Text = x.Name }).ToList(), TypeSelectItem = types.Select(x => new SelectListItem { Value = $"{x.Id}", Text = x.Name }).ToList() }; return(TimesheetViewModel); }
public bool Update(TimesheetViewModel timesheetVm) { timesheetVm.TotalWorkday = timesheetVm.Day_1 + timesheetVm.Day_2 + timesheetVm.Day_3 + timesheetVm.Day_4 + timesheetVm.Day_5 + timesheetVm.Day_6 + timesheetVm.Day_7 + timesheetVm.Day_8 + timesheetVm.Day_9 + timesheetVm.Day_10 + timesheetVm.Day_11 + timesheetVm.Day_12 + timesheetVm.Day_13 + timesheetVm.Day_14 + timesheetVm.Day_15 + timesheetVm.Day_16 + timesheetVm.Day_17 + timesheetVm.Day_18 + timesheetVm.Day_19 + timesheetVm.Day_20 + timesheetVm.Day_21 + timesheetVm.Day_22 + timesheetVm.Day_23 + timesheetVm.Day_24 + timesheetVm.Day_25 + timesheetVm.Day_26 + timesheetVm.Day_27 + timesheetVm.Day_28 + timesheetVm.Day_29 + timesheetVm.Day_30 + timesheetVm.Day_31; timesheetVm.TotalSalary = timesheetVm.SalaryOfDay * Convert.ToDecimal(timesheetVm.TotalWorkday) + timesheetVm.Allowance + timesheetVm.Bonus - timesheetVm.InsurancePremiums; timesheetVm.TotalActualSalary = timesheetVm.SalaryOfDay * Convert.ToDecimal(timesheetVm.TotalWorkday) + timesheetVm.Allowance + timesheetVm.Bonus - timesheetVm.AdvancePayment - timesheetVm.InsurancePremiums; var timeSheet = Mapper.Map <TimesheetViewModel, Timesheet>(timesheetVm); _timesheetRepository.Update(timeSheet); return(true); }
public JsonResult SaveTimesheetEntries(TimesheetViewModel model) { string userName = this.membershipService.GetCurrentUserName(); model.TimesheetChecker = userName; return Json(timesheetService.SaveTimeSheet(model), JsonRequestBehavior.AllowGet); }
public JsonResult SubmitTimesheet(TimesheetViewModel model) { return Json(timesheetService.SubmitTimeSheet(model), JsonRequestBehavior.AllowGet); }
public JsonResult MarkAsPending(TimesheetViewModel model) { return Json(timesheetService.MarkAsPending(model)); }
public JsonResult MarkAsCompleted(TimesheetViewModel model) { string userName = this.membershipService.GetCurrentUserName(); model.TimesheetChecker = userName; return Json(timesheetService.MarkAsCompleted(model)); }
public JsonResult AssociateRejectTimesheet(TimesheetViewModel model) { return Json(timesheetService.AssociateRejectTimesheet(model), JsonRequestBehavior.AllowGet); }
public JsonResult ApproveTimesheet(TimesheetViewModel model) { return Json(timesheetService.ApproveTimesheet(model), JsonRequestBehavior.AllowGet); }
public ActionResult Timesheet(int id) { var activeRecords = this.areas.GetById(id).Records .Where(r => r.Status == RecordStatus.Active); var timesheetViewModel = new TimesheetViewModel { MinYear = activeRecords.Min(a => a.DateCreated).Year, MaxYear = activeRecords.Max(a => a.FinishingDate).Value.Year, Events = activeRecords }; return View("Timesheet", timesheetViewModel); }