diff --git a/Machete.Data/Initialize/MacheteReportDefinitions.cs b/Machete.Data/Initialize/MacheteReportDefinitions.cs index 46760cf9a..fae026f8c 100644 --- a/Machete.Data/Initialize/MacheteReportDefinitions.cs +++ b/Machete.Data/Initialize/MacheteReportDefinitions.cs @@ -1340,6 +1340,27 @@ join lookups l on (ev.eventType = l.id) WHERE (w.dwccardnum = @dwccardnum)", inputsJson = "{\"beginDate\":false,\"endDate\":false,\"memberNumber\":true}" }, + // Worker Details -- activities + new ReportDefinition + { + name = "WorkerDetailsActivities", + commonName = "Worker Details, Activities attended", + description = + " A list of activities that a given worker attended", + category = "WorkerDetail", + sqlquery = + @"SELECT +a.nameEN as [Activity Name], +a.typeEN as [Activity Type], +a.teacher as [Teacher], +CONVERT(varchar, a.dateStart, 22) as [Start Time] +FROM ActivitySignins asi +JOIN Activities a +on asi.ActivityID = a.ID +WHERE asi.dwccardnum = @dwccardnum +", + inputsJson = "{\"beginDate\":false,\"endDate\":false,\"memberNumber\":true}" + }, // Worker details -- jobs summary new ReportDefinition { diff --git a/Machete.Data/Repositories/AllRepositories.cs b/Machete.Data/Repositories/AllRepositories.cs index 46704230d..ea2a3dc2a 100644 --- a/Machete.Data/Repositories/AllRepositories.cs +++ b/Machete.Data/Repositories/AllRepositories.cs @@ -60,7 +60,7 @@ public interface IEmailRepository : IRepository public interface IWorkOrderRepository : IRepository { - IEnumerable GetActiveOrders(DateTime date); + IEnumerable GetActiveOrders(DateTime date, TimeZoneInfo clientTimeZoneInfo); } public interface IWorkerRequestRepository : IRepository { WorkerRequest GetByID(int woid, int workerID); @@ -163,10 +163,13 @@ public class WorkOrderRepository : RepositoryBase, IWorkOrderReposito { public WorkOrderRepository(IDatabaseFactory databaseFactory) : base(databaseFactory) { } - public IEnumerable GetActiveOrders(DateTime date) + public IEnumerable GetActiveOrders(DateTime date, TimeZoneInfo clientTimeZoneInfo) { + // date parameter comes in as Utc datetime, so convert before comparing + DateTime clientDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.SpecifyKind(date, DateTimeKind.Unspecified), clientTimeZoneInfo); + return dbset.Where(wo => wo.statusID == WorkOrder.iActive - && wo.dateTimeofWork.Date == date.Date) + && TimeZoneInfo.ConvertTimeFromUtc(DateTime.SpecifyKind(wo.dateTimeofWork, DateTimeKind.Unspecified), clientTimeZoneInfo).Date == clientDate.Date) .Include(a => a.Employer) .Include(a => a.workerRequestsDDD) .ThenInclude(a => a.workerRequested) diff --git a/Machete.Service/WorkOrderService.cs b/Machete.Service/WorkOrderService.cs index 0478aaeae..5ab7e902a 100644 --- a/Machete.Service/WorkOrderService.cs +++ b/Machete.Service/WorkOrderService.cs @@ -109,7 +109,7 @@ ITenantService tenantService /// WorkOrders associated with a given date that are active public IEnumerable GetActiveOrders(DateTime date, bool assignedOnly) { - var matching = repo.GetActiveOrders(date); + var matching = repo.GetActiveOrders(date, _clientTimeZoneInfo); // .Where(wo => wo.statusID == WorkOrder.iActive // && wo.dateTimeofWork.Date == date.Date).ToList(); diff --git a/Machete.Web/Controllers/Legacy/AccountController.cs b/Machete.Web/Controllers/Legacy/AccountController.cs index a802e18fb..d25db2a14 100644 --- a/Machete.Web/Controllers/Legacy/AccountController.cs +++ b/Machete.Web/Controllers/Legacy/AccountController.cs @@ -213,6 +213,12 @@ public async Task Register(RegisterViewModel model) { if (!ModelState.IsValid) return View(model); var newUserName = model.FirstName.Trim() + "." + model.LastName.Trim(); + var dupeUser = await _userManager.FindByEmailAsync(model.Email); + if (dupeUser != null && dupeUser.Email == model.Email) + { + ModelState.AddModelError("", ValidationStrings.dupeEmail); + return View(model); + } var user = new MacheteUser { UserName = newUserName, LoweredUserName = newUserName.ToLower(), ApplicationId = GetApplicationId(), Email = model.Email.Trim(), LoweredEmail = model.Email.Trim() }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) @@ -224,7 +230,9 @@ public async Task Register(RegisterViewModel model) foreach (var error in result.Errors) { - ModelState.AddModelError(error.Code, error.Description); + ModelState.AddModelError("", error.Description); + if (error.Description.Contains("is invalid, can only contain letters or digits") && newUserName.Contains(" ")) + ModelState.AddModelError("", ValidationStrings.NameHasSpace); } // If we got this far, something failed, redisplay form @@ -354,8 +362,14 @@ public async Task Edit([Bind]EditUserViewModel model) { var user = _context.Users.First(u => u.Id == model.Id); var macheteUserName = model.FirstName.Trim() + "." + model.LastName.Trim(); + var dupeUser = await _userManager.FindByEmailAsync(model.Email); user.UserName = macheteUserName; user.LoweredUserName = macheteUserName.ToLower(); + if (dupeUser != null && dupeUser.Email == model.Email) + { + ModelState.AddModelError("ErrorMessage", ValidationStrings.dupeEmail); + return View(model); + } user.Email = model.Email.Trim(); user.LoweredEmail = model.Email.Trim().ToLower(); user.IsApproved = model.IsApproved; diff --git a/Machete.Web/Resources/ValidationStrings.Designer.cs b/Machete.Web/Resources/ValidationStrings.Designer.cs index b1ebe669a..a223f4ef4 100644 --- a/Machete.Web/Resources/ValidationStrings.Designer.cs +++ b/Machete.Web/Resources/ValidationStrings.Designer.cs @@ -149,6 +149,15 @@ public static string emailValidation { return ResourceManager.GetString("emailValidation", resourceCulture); } } + + /// + /// Looks up a localized string to duplicate email error on Create. + /// + public static string dupeEmail { + get { + return ResourceManager.GetString("dupeEmail", resourceCulture); + } + } /// /// Looks up a localized string similar to First Name. @@ -311,6 +320,15 @@ public static string Register { return ResourceManager.GetString("Register", resourceCulture); } } + + /// + /// Looks up a localized string similar to NameHasSpace. + /// + public static string NameHasSpace { + get { + return ResourceManager.GetString("NameHasSpace", resourceCulture); + } + } /// /// Looks up a localized string similar to Use the form below to create a new account.. diff --git a/Machete.Web/Resources/ValidationStrings.es.resx b/Machete.Web/Resources/ValidationStrings.es.resx index 9e5dbc47b..ff3fcdc06 100644 --- a/Machete.Web/Resources/ValidationStrings.es.resx +++ b/Machete.Web/Resources/ValidationStrings.es.resx @@ -156,6 +156,9 @@ Contraseña nueva + + Nombre y apellido no pueden contener espacios. Por favor, usar un guión "-" para unir dos palabras + Crear una cuenta @@ -219,6 +222,9 @@ The email format is invalid + + Intente denuevo con otro email + Invalid username or password. diff --git a/Machete.Web/Resources/ValidationStrings.resx b/Machete.Web/Resources/ValidationStrings.resx index 4b4c9db18..0cfb1b05f 100644 --- a/Machete.Web/Resources/ValidationStrings.resx +++ b/Machete.Web/Resources/ValidationStrings.resx @@ -174,6 +174,9 @@ New Password + + Last name and first name must not contain spaces. To enter a name with multiple words, use hyphens "-" + Register @@ -231,6 +234,9 @@ The email format is invalid + + Please try a different email + Invalid username or password.