public ActionResult UpliftApprove(int EmpID) { //Creating List List <Uplift> ObjEmp = new List <Uplift>(); var data = _TimeSheetApprovalMethod.getUpliftApprove(EmpID); if (data.Count > 0) { foreach (var details in data) { Uplift datamodel = new Uplift(); datamodel.Id = details.DetailId; datamodel.EmployeeId = details.EmployeeId; datamodel.Name = details.Name; datamodel.Day = details.day; datamodel.Date = details.Date; datamodel.UpliftPosition = Convert.ToInt32(details.UpliftPostionId); datamodel.Hours = details.Hours; // datamodel.EndTimeHr = details.EndTime; datamodel.Project = details.Project; datamodel.Customer = details.Customer; datamodel.FileName = details.FileName; datamodel.ChangeInCustomerRate = Convert.ToDecimal(details.CustomerRate); datamodel.ChangeInWorkerRate = Convert.ToDecimal(details.WorkerRate); datamodel.totalUpliftHr = CountTotalUpliftHrInYear(EmpID); TempData["UpliftWName"] = details.Name; TempData["UpliftWId"] = details.EmployeeId; ObjEmp.Add(datamodel); } } return(PartialView("_partialUpliftApproval", ObjEmp)); }
public TimeSpan CountTotalUpliftHrInYear(int EmpID) { TimeSpan totalHr = new TimeSpan(0, 0, 0); double total = 0; string currentYear = Convert.ToString(_TimeSheetApprovalMethod.getCurruentYear()); Uplift ObjEmp = new Uplift(); var data = _TimeSheetApprovalMethod.getUpliftApprove(EmpID); foreach (var item in data) { string str = item.Date.Split('-')[0]; TimeSpan t = TimeSpan.Parse(item.Hours); //int hr = Convert.ToInt16(item.Hours.Split(':')[0]); //int min = Convert.ToInt16(item.Hours.Split(':')[1]); //int sumHours = 0; //int sumMinutes = 0; if (currentYear == str) { //totalHr = totalHr + Convert.ToDouble(item.Hours); //hr = sumHours + (sumMinutes / 60); //min =sumMinutes; totalHr = totalHr.Add(t); } } return(totalHr); }
public JsonResult UpliftApprove(int EmpID) { //Creating List List <Uplift> ObjEmp = new List <Uplift>(); var data = _TimeSheetApprovalMethod.getUpliftApprove(EmpID); if (data.Count > 0) { foreach (var details in data) { Uplift datamodel = new Uplift(); datamodel.Id = details.Id; datamodel.EmployeeId = details.EmployeeId; datamodel.Name = details.Name; datamodel.Day = details.day; datamodel.Date = details.Date; datamodel.UpliftPosition = Convert.ToInt32(details.UpliftPostionId); datamodel.Hours = details.Hours; // datamodel.EndTimeHr = details.EndTime; datamodel.Project = details.Project; datamodel.Customer = details.Customer; datamodel.ChangeInCustomerRate = Convert.ToDecimal(details.CustomerRate); datamodel.ChangeInWorkerRate = Convert.ToDecimal(details.WorkerRate); ObjEmp.Add(datamodel); } } //return list as Json return(Json(ObjEmp, JsonRequestBehavior.AllowGet)); }