public CheckTACredentialsResponse CheckTACredentials(CheckTACredentialsRequest request, dbDataContext db) { var today = DateTime.Today; var loginParameters = new HappyHoursLoginParameters() { Credentials = new HappyHoursCredentials() { Username = request.TAEmail, Password = request.TAPassword, Number = request.TANumber }, StartDate = new DateTime(today.Year, today.Month, 1), EndDate = today }; HappyHoursCoreBL manager = new HappyHoursCoreBL(); try { HappyHourSummary summaryResult = manager.GetSummary(loginParameters); } catch { return(new CheckTACredentialsResponse() { Valid = false }); } return(new CheckTACredentialsResponse() { Valid = true }); }
private void CheckUserArrivalTime(User user, dbDataContext db) { var decryptedSystemPassword = PasswordEncryptor.Decrypt(user.SystemPassword); var decryptedSystemNumber = PasswordEncryptor.Decrypt(user.SystemNumber); var today = DateTime.Today; var loginParameters = new HappyHoursLoginParameters() { Credentials = new HappyHoursCredentials() { Username = user.SystemEmail, Password = decryptedSystemPassword, Number = decryptedSystemNumber }, StartDate = new DateTime(today.Year, today.Month, today.Day), EndDate = new DateTime(today.Year, today.Month, today.Day) }; HappyHoursCoreBL manager = new HappyHoursCoreBL(); HappyHourSummary summaryResult = manager.GetSummary(loginParameters); var dayHour = summaryResult.DayDetails.FirstOrDefault(); if (dayHour == null) { return; } HandleUserTime(user, dayHour, summaryResult.User, db); }
public UserInformationResponse GetUserInformation(UserInformationRequest request, long userId, dbDataContext db) { var user = GetUserDetails(userId, db); int month = 0; if (request == null || request.Month == null) { month = DateTime.Today.Month; } else { month = request.Month.Value; } //var today = DateTime.Today; // new DateTime(2017, 8, 1).Date; var startDate = new DateTime(DateTime.Today.Year, month, 1); int daysInMonth = 0; if (month == DateTime.Today.Month) { daysInMonth = DateTime.Today.Day; } else { daysInMonth = DateTime.DaysInMonth(DateTime.Today.Year, month); } var endDate = new DateTime(DateTime.Today.Year, month, daysInMonth); var decryptedSystemPassword = PasswordEncryptor.Decrypt(user.SystemPassword); var decryptedSystemNumber = PasswordEncryptor.Decrypt(user.SystemNumber); var loginParameters = new HappyHoursLoginParameters() { Credentials = new HappyHoursCredentials() { Username = user.SystemEmail, Password = decryptedSystemPassword, Number = decryptedSystemNumber }, StartDate = startDate, EndDate = endDate //today // new DateTime(2017, 8, 31).Date }; HappyHoursCoreBL manager = new HappyHoursCoreBL(); HappyHourSummary summaryResult = manager.GetSummary(loginParameters); IList <MonthDetails> months = new List <MonthDetails>(); CultureInfo usEnglish = new CultureInfo("en-US"); for (var i = 1; i <= DateTime.Today.Month; i++) { months.Add(new MonthDetails() { Month = i, Name = usEnglish.DateTimeFormat.GetMonthName(i) }); } return(new UserInformationResponse() { FirstName = user.FirstName, LastName = user.LastName, ExtraMinutes = summaryResult.ExtraMinutes, LackMinutes = summaryResult.LackMinutes, Days = summaryResult.DayDetails.Select(c => new DayTimeDetails() { ExtraMinutes = c.ExtraMinutes, LackMinutes = c.LackMinutes, Date = HappyHourTimestampProvider.GetDateTimestamp(c.Date), StartTime = HappyHourTimestampProvider.GetDateTimeTimestamp(c.StartTime), EndTime = HappyHourTimestampProvider.GetDateTimeTimestamp(c.EndTime), Day = c.Day }).ToList(), Months = months }); }