private void EndShift(string username, string password, decimal totalHotel, decimal totalBar, decimal totalSales, string closeShift) { var person = AppSecurity.GetUser(username, password); var today = DateTime.Today.ToShortDateString(); var es = _employeeShiftService.GetAll(2).Where(x => x.PersonId == person.PersonID && x.ShiftDate.ToShortDateString().Equals(today)).LastOrDefault(); if (es == null) { EmployeeShift employeeShift = new EmployeeShift(); employeeShift.ShiftDate = DateTime.Now; employeeShift.StartTime = DateTime.Now; employeeShift.EndTime = DateTime.Now; employeeShift.PersonId = person.PersonID; employeeShift.TotalSales = decimal.Zero; employeeShift.TotalHotelSalesRecievable = decimal.Zero; employeeShift.TotalBarSalesRecievable = decimal.Zero; employeeShift.CloseMethod = "OPEN"; _employeeShiftService.Create(employeeShift); } else { es.EndTime = DateTime.Now; es.TotalSales = totalSales; es.CloseMethod = closeShift; es.TotalHotelSalesRecievable = totalHotel; es.TotalBarSalesRecievable = totalBar; _employeeShiftService.Update(es); } }
private void CreateShift(string username, string password) { var person = AppSecurity.GetUser(username, password); var today = DateTime.Today.ToShortDateString(); var es = _employeeShiftService.GetAll(2).FirstOrDefault(x => x.ShiftDate.ToShortDateString().Equals(today) && x.PersonId == person.PersonID); if (es == null) { EmployeeShift employeeShift = new EmployeeShift(); employeeShift.ShiftDate = DateTime.Now; employeeShift.StartTime = DateTime.Now; employeeShift.EndTime = null; employeeShift.PersonId = person.PersonID; employeeShift.TotalSales = decimal.Zero; employeeShift.TotalHotelSalesRecievable = decimal.Zero; employeeShift.TotalBarSalesRecievable = decimal.Zero; employeeShift.CloseMethod = "OPEN"; _employeeShiftService.Create(employeeShift); } }