private string GetStatus(Timesheets log) { string status = Common.Constants.NoStatus; if (log == null) { return(status); } DateTime date = DateTime.MinValue; foreach (var column in Constants.Columns) { var prop = GetPropValue(log, column); var value = prop.GetValue(log); if (value != null) { var newDate = Convert.ToDateTime(value); if (newDate > date) { date = newDate; status = prop.Name; } } } return(status); }
public async Task <IActionResult> Edit(int id, [Bind("AttendanceId,EmployeeId,TimeIn,TimeOut,AttendanceDate,ShiftId,ApprovalStatus")] Timesheets timesheets) { if (id != timesheets.AttendanceId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(timesheets); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetsExists(timesheets.AttendanceId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeId", timesheets.EmployeeId); ViewData["ShiftId"] = new SelectList(_context.Shift, "ShiftId", "ShiftId", timesheets.ShiftId); return(View(timesheets)); }
public ActionResult Edit(TimeSheetsViewModel model) { Timesheets tsv = new Timesheets(); //tsv.Id_Timesheet = model.Id_Timesheet; tsv.StartTime = model.StartTime.GetValueOrDefault(); tsv.StopTime = model.StopTime.GetValueOrDefault(); tsv.Comments = model.Comments; tsv.WorkComplete = model.WorkComplete; tsv.LastModifiedAt = DateTime.Now; tsv.DeletedAt = model.DeletedAt.GetValueOrDefault(); tsv.Active = model.Active; int employeeId = int.Parse(model.FirstName); if (employeeId > 0) { Employees emp = db.Employees.Find(employeeId); tsv.Id_Employee = emp.Id_Employee; } int employeeLastId = int.Parse(model.LastName); if (employeeLastId > 0) { Employees emp = db.Employees.Find(employeeLastId); tsv.Id_Employee = emp.Id_Employee; } ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", tsv.Id_Customer); ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", tsv.Id_Contractor); db.SaveChanges(); return(View("Index")); }
}//create // GET: Timesheets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Timesheets timesheetdetail = db.Timesheets.Find(id); if (timesheetdetail == null) { return(HttpNotFound()); } TimeSheetsViewModel view = new TimeSheetsViewModel(); view.Id_Timesheet = timesheetdetail.Id_Timesheet; view.StartTime = timesheetdetail.StartTime.GetValueOrDefault(); view.StopTime = timesheetdetail.StopTime.GetValueOrDefault(); view.Comments = timesheetdetail.Comments; view.WorkComplete = timesheetdetail.WorkComplete; view.LastModifiedAt = timesheetdetail.LastModifiedAt.GetValueOrDefault(); view.DeletedAt = timesheetdetail.DeletedAt.GetValueOrDefault(); view.Active = timesheetdetail.Active; view.Id_Employee = timesheetdetail.Id_Employee; view.FirstName = timesheetdetail.Employees?.FirstName; view.LastName = timesheetdetail.Employees?.LastName; ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", view.Id_Customer); ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", view.Id_Contractor); return(View(view)); }
// GET: Timesheets/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Timesheets timesheetdetail = db.Timesheets.Find(id); if (timesheetdetail == null) { return(HttpNotFound()); } TimeSheetsViewModel view = new TimeSheetsViewModel(); view.Id_Timesheet = timesheetdetail.Id_Timesheet; view.StartTime = timesheetdetail.StartTime; view.StopTime = timesheetdetail.StopTime; view.Comments = timesheetdetail.Comments; view.WorkComplete = timesheetdetail.WorkComplete; view.CreatedAt = timesheetdetail.CreatedAt; view.LastModifiedAt = DateTime.Now; view.DeletedAt = DateTime.Now; view.Active = timesheetdetail.Active; view.Id_Employee = timesheetdetail.Id_Employee; view.FirstName = timesheetdetail.Employees?.FirstName; view.LastName = timesheetdetail.Employees?.LastName; return(View(view)); }
public ActionResult Edit_Timesheet(int Id) { Timesheets timesheet = context.Timesheets1.Find(Id); ViewBag.Projects = context.Projects.ToList(); return(PartialView(timesheet)); }
private void ChangeTimeSheetStatus(int Id, int Status) { Timesheets timesheet = context.Timesheets1.Where(x => x.Id == Id).FirstOrDefault(); timesheet.Status_Id = Status; context.SaveChanges(); }
public void GetStaffHourlyRate_HourlyRateGreaterThan50_ReturnsErrorMessage(double testValue) { var timesheets = new Timesheets(); var result = timesheets.SetStaffHourlyRate(testValue); Assert.That(result, Is.EqualTo("The Hourly Rate cannot exceed 50 ")); }
public void GetStaffHourlyRate_HourlyRateGreaterThan1AndLessThanOrEqualTo50_ReturnsAcceptedValueMessage(double testValue) { var timesheets = new Timesheets(); var result = timesheets.SetStaffHourlyRate(testValue); Assert.That(result, Is.EqualTo("Value within range")); }
public void GetStaffHourlyRate_HourlyRateLessThan1_ReturnInvalidErrorMessage(double testValue) { var timesheet = new Timesheets(); var result = timesheet.SetStaffHourlyRate(testValue); Assert.That(result, Is.EqualTo("Invalid Hourly rate")); }
public ActionResult DeleteConfirmed(int id) { Timesheets timesheets = db.Timesheets.Find(id); db.Timesheets.Remove(timesheets); db.SaveChanges(); return(RedirectToAction("Index")); }
private Timesheets SetStatus(Timesheets timesheet, string status) { var statusRecord = _work.TimesheetStatusRepo.Get(x => x.Name.ToLower() == status.ToLower()).FirstOrDefault(); if (statusRecord != null) { timesheet.StatusID = statusRecord.ID; } return(timesheet); }
public ActionResult Delete_Timesheet(int Id) { Timesheets timesheet = context.Timesheets1.Find(Id); timesheet.Updated_Date = DateTime.Now; timesheet.is_Deleted = true; context.SaveChanges(); List <Timesheets> timesheets = context.Timesheets1.Where(x => x.User == HttpContext.User.Identity.Name && x.is_Deleted != true).ToList(); return(PartialView("_ViewTimesheet", timesheets)); }
public void GetTotalHoursForWeek(double hrsForSunday, double hrsForMonday, double hrsForTuesday, double hrsForWednesday, double hrsForThursday, double hrsForFriday, double hrsForSaturday) { var timesheet = new Timesheets(); var setRatePerHour = timesheet.SetStaffHourlyRate(40); var result = timesheet.CalculateHoursForWeek(hrsForSunday, hrsForMonday, hrsForTuesday, hrsForWednesday, hrsForThursday, hrsForFriday, hrsForSaturday); Assert.That(result, Is.EqualTo(19)); }
public void Menu_011_Timesheets() { var _menu = new MainMenuPage(_driver); Assert.IsTrue(_menu.MenuContainer.Displayed); _menu.TimesheetsTabBtn.Click(); SwitchToContent(); var _timesheetsPage = new Timesheets(_driver); _timesheetsPage.WaitElementIsShown(_timesheetsPage.Form); Assert.IsTrue(_timesheetsPage.IsDisplayed()); }
public async Task <IActionResult> Create([Bind("AttendanceId,EmployeeId,TimeIn,TimeOut,AttendanceDate,ShiftId,ApprovalStatus")] Timesheets timesheets) { if (ModelState.IsValid) { _context.Add(timesheets); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeId", timesheets.EmployeeId); ViewData["ShiftId"] = new SelectList(_context.Shift, "ShiftId", "ShiftId", timesheets.ShiftId); return(View(timesheets)); }
public void ApplyPenaltyRates_OnSaturday(double hrsForSunday, double hrsForMonday, double hrsForTuesday, double hrsForWednesday, double hrsForThursday, double hrsForFriday, double hrsForSaturday) { var timesheet = new Timesheets(); var setRatePerHour = timesheet.SetStaffHourlyRate(40); var hrsForWeek = timesheet.CalculateHoursForWeek(hrsForSunday, hrsForMonday, hrsForTuesday, hrsForWednesday, hrsForThursday, hrsForFriday, hrsForSaturday); var costForTheWeek = timesheet.CalculateCostForTheWeek(); var result = timesheet.Apply_PenaltyRateOfOneAndHalfPercent_OnSaturday(); Assert.That(result, Is.EqualTo(0.59999999999999998d)); }
// GET: Timesheets/Details/5 public ActionResult Details(int?id) { TimeSheetsViewModel model = new TimeSheetsViewModel(); MobileWorkDataEntities entities = new MobileWorkDataEntities(); try { Timesheets timesheetdetail = entities.Timesheets.Find(id); if (timesheetdetail == null) { return(HttpNotFound()); } // muodostetaan näkymämalli tietokannan rivien pohjalta TimeSheetsViewModel view = new TimeSheetsViewModel(); view.Id_Timesheet = timesheetdetail.Id_Timesheet; view.StartTime = timesheetdetail.StartTime.GetValueOrDefault(); view.StopTime = timesheetdetail.StopTime.GetValueOrDefault(); view.Comments = timesheetdetail.Comments; view.WorkComplete = timesheetdetail.WorkComplete; view.CreatedAt = timesheetdetail.CreatedAt.GetValueOrDefault(); view.LastModifiedAt = timesheetdetail.LastModifiedAt.GetValueOrDefault(); view.DeletedAt = timesheetdetail.DeletedAt.GetValueOrDefault(); view.Active = timesheetdetail.Active; view.Id_Employee = timesheetdetail.Id_Employee; view.FirstName = timesheetdetail.Employees?.FirstName; view.LastName = timesheetdetail.Employees?.LastName; view.Id_Customer = timesheetdetail.Customers?.Id_Customer; view.CustomerName = timesheetdetail.Customers?.CustomerName; ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", null); view.Id_Contractor = timesheetdetail.Contractors?.Id_Contractor; view.CompanyName = timesheetdetail.Contractors?.CompanyName; ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", null); view.Id_WorkAssignment = timesheetdetail.WorkAssignments?.Id_WorkAssignment; view.Title = timesheetdetail.WorkAssignments?.Title; model = view; } finally { entities.Dispose(); } return(View(model)); }//details
public WorkModel GetDetailModel(string Details) { panconDatabaseEntities entities = new panconDatabaseEntities(); string[] Sheet = Details.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); int count = Sheet.Count(); string workid = Sheet[count - 2]; Timesheets sheet = (from ts in entities.Timesheets where (ts.WorkAssignmentId.ToString() == workid) select ts).FirstOrDefault(); string cont = (from con in entities.Contractors where (con.ContractorId == sheet.ContractorId) select con.CompanyName).Single(); string cust = (from c in entities.Customers where (c.CustomerId == sheet.CustomerId) select c.CustomerName).Single(); string work = (from co in entities.WorkAssignments where (co.WorkAssignmentId == sheet.WorkAssignmentId) select co.Title).Single(); string emp = (from e in entities.Employees where (e.EmployeeId == sheet.EmployeeId) select e.Firstname + " " + e.Lastname).Single(); double workTime = (sheet.StopTime.Value - sheet.StartTime.Value).TotalHours; string comments = (from ct in entities.Timesheets where (ct.TimesheetId == sheet.TimesheetId) select ct.Comments).Single(); WorkModel details = new WorkModel() { CustomerName = cust, ContractorName = cont, Firstname = emp, WorkTitle = work, CountedHours = workTime, Comments = comments }; return(details); }
private PropertyInfo GetPropValue(Timesheets log, string name = "") { if (log != null) { var type = log.GetType(); var properties = type.GetProperties(); foreach (var prop in properties) { if (prop.Name.Replace(" ", "").ToLower() == name.ToLower()) { return(prop); // break; } } } return(null); }
public ActionResult Create(TimeSheetsViewModel model) { MobileWorkDataEntities entities = new MobileWorkDataEntities(); Timesheets tsv = new Timesheets(); tsv.Id_Timesheet = model.Id_Timesheet; tsv.StartTime = model.StartTime; tsv.StopTime = model.StopTime; tsv.Comments = model.Comments; tsv.CreatedAt = DateTime.Now; tsv.LastModifiedAt = DateTime.Now; tsv.Active = model.Active; db.Timesheets.Add(tsv); int employeeId = int.Parse(model.FirstName); if (employeeId > 0) { Employees emp = db.Employees.Find(employeeId); tsv.Id_Employee = emp.Id_Employee; } int employeeLastId = int.Parse(model.LastName); if (employeeLastId > 0) { Employees emp = db.Employees.Find(employeeLastId); tsv.Id_Employee = emp.Id_Employee; } ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", null); ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", null); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }//create
public ActionResult New_Timesheet(Timesheets timesheet) { if (ModelState.IsValid) { timesheet.Updated_Date = DateTime.Now; timesheet.is_Deleted = false; timesheet.Status_Id = 3; context.Timesheets1.Add(timesheet); context.SaveChanges(); ViewBag.Projects = context.Projects.ToList(); return(PartialView("_NewTimeSheet")); } else { return(View("Error")); } }
public ActionResult Edit_Timesheet(Timesheets Updatedtimesheet) { Timesheets Savedtimesheet = context.Timesheets1.Find(Updatedtimesheet.Id); Savedtimesheet.Project_Name = Updatedtimesheet.Project_Name; Savedtimesheet.date = Updatedtimesheet.date; Savedtimesheet.TimeSpent = Updatedtimesheet.TimeSpent; Savedtimesheet.Workdone = Updatedtimesheet.Workdone; Savedtimesheet.Mode = Updatedtimesheet.Mode; Savedtimesheet.Updated_Date = DateTime.Now; context.SaveChanges(); List <Timesheets> timesheets = context.Timesheets1.Where(x => x.User == HttpContext.User.Identity.Name && x.is_Deleted != true).ToList(); return(PartialView("_ViewTimesheet", timesheets)); }
public Timesheets AddTimesheet(Create addTimesheet) { var timesheet = new Timesheets { SelectedProject = addTimesheet.SelectedProject, SelectedActivity = addTimesheet.SelectedActivity, FromTime = addTimesheet.FromTime, ToTime = addTimesheet.ToTime, TotalHours = addTimesheet.TotalHours, DateBooked = addTimesheet.DateBooked, Comment = addTimesheet.Comment }; _context.Add(timesheet); _context.SaveChanges(); return(timesheet); }
private List <DailyLog> GetDailyLogs(Timesheets log, int groupID = 0) { List <DailyLog> dailyLogs = new List <DailyLog>(); if (log.SplitLogId.HasValue && log.SplitLogId.Value > 0) { return(null); } foreach (var column in Constants.Columns) { var prop = GetPropValue(log, column); var value = prop.GetValue(log); var idProp = GetPropValue(log, "ID"); var idVal = idProp.GetValue(log); if (prop.Name.ToLower() == Constants.Columns[1].ToLower()) { var isAutoSplitProp = GetPropValue(log, "IsAutoSplit"); var isAutoSplitVal = (bool)isAutoSplitProp.GetValue(log); if (isAutoSplitVal) { var splitLog = _work.DailyPunchLogsRepo.Get(x => x.SplitLogId.HasValue && x.SplitLogId.Value == log.ID).FirstOrDefault(); value = splitLog.ClockedOut; } } if (value != null) { var time = Convert.ToDateTime(value); var dailyLog = new DailyLog { ID = (int)idVal, PunchName = prop.Name, PunchTime = time, Time = time.ToString("HH:mm"), PunchDate = time.Date, GroupID = groupID }; dailyLogs.Add(dailyLog); } } return(dailyLogs); }
private Timesheet GetActualTimesheet() { var actualTime = GetActualTime(); var actualTimesheet = Timesheets.FirstOrDefault(timesheet => timesheet.Month == actualTime.Month && timesheet.Year == actualTime.Year); if (actualTimesheet == null) { actualTimesheet = new Timesheet { Month = actualTime.Month, Year = actualTime.Year }; Timesheets.Insert(0, actualTimesheet); } return(actualTimesheet); }
public async Task DeleteTimesheet() { var service = await GetInMemoryProjectService().ConfigureAwait(false); const int timesheetID = 2; const string selectedProject = "Vodacom 2"; const string selectedActivity = "Vodacom Projects 2"; TimeSpan fromTime = new TimeSpan(08, 30, 00); TimeSpan toTime = new TimeSpan(16, 00, 00); const int totalHours = 8; DateTime dateBooked = new DateTime(2020, 06, 4, 00, 00, 00, 000); const string comment = "I was busy with vodacom project 2"; Timesheets timesheet = new Timesheets() { TimesheetID = timesheetID, SelectedProject = selectedProject, SelectedActivity = selectedActivity, FromTime = fromTime, ToTime = toTime, TotalHours = totalHours, DateBooked = dateBooked, Comment = comment }; var timesheetCreated = service.AddTimesheet(new Proxy.Models.Timesheet.Create { SelectedProject = selectedProject, SelectedActivity = selectedActivity, FromTime = fromTime, ToTime = toTime, TotalHours = totalHours, DateBooked = dateBooked, Comment = comment }); var result = service.GetAllTimesheets().First(); var timesheetDeleted = service.DeleteTimesheet(result.TimesheetID); Assert.NotNull(timesheetDeleted); }
protected async Task ExecuteLoadItemsCommand() { if (IsLoading) { return; } IsLoading = true; try { Timesheets.Clear(); var timesheets = await TimesheetService.GetTimesheetEntries(); foreach (var timesheet in timesheets) { Timesheets.Add(new TimesheetEntryViewModel(timesheet)); } } finally { IsLoading = false; } }
private Timesheets SetPropValue(DailyLog log) { var dailyPunchLog = _work.DailyPunchLogsRepo.GetByID(log.ID); //DailyLogForInsert(log.PunchTime) ; if (dailyPunchLog == null) { dailyPunchLog = new Timesheets(); } List <DailyLog> dailyLogs = new List <DailyLog>(); var type = typeof(Timesheets); var properties = type.GetProperties(); var propName = log.PunchName.Replace(" ", "").ToLower(); foreach (var prop in properties) { if (prop.Name.Replace(" ", "").ToLower() == propName) { prop.SetValue(dailyPunchLog, log.PunchTime); } } return(dailyPunchLog); }
[HttpPost] //verbiattribuutti public bool PostStatus(WorkAssignmentOperationModel input) { MobileWorkDataEntities entities = new MobileWorkDataEntities(); try { WorkAssignments assignment = (from wa in entities.WorkAssignments where (wa.Active == true) && (wa.Title == input.AssignmentTitle) select wa).FirstOrDefault(); if (assignment == null) { return(false); } //NumberStyles style; //CultureInfo provider; //provider = new CultureInfo("fi-FI"); //string valueString = input.Latitude.ToString("R", CultureInfo.InvariantCulture); //style = NumberStyles.AllowDecimalPoint; if (input.Operation == "Start") { int assignmentId = assignment.Id_WorkAssignment; Timesheets newEntry = new Timesheets() { Id_WorkAssignment = assignmentId, StartTime = DateTime.Now, WorkComplete = false, Active = true, CreatedAt = DateTime.Now }; entities.Timesheets.Add(newEntry); } else if (input.Operation == "Stop") { int assignmentId = assignment.Id_WorkAssignment; Timesheets existing = (from ts in entities.Timesheets where (ts.Id_WorkAssignment == assignmentId) && (ts.Active == true) && (ts.WorkComplete == false) orderby ts.StartTime descending select ts).FirstOrDefault(); if (existing != null) { existing.StopTime = DateTime.Now; existing.WorkComplete = true; existing.LastModifiedAt = DateTime.Now; } else { return(false); } } entities.SaveChanges(); } catch { return(false); } finally { entities.Dispose(); } return(true); }