public async Task TestSearchByKeywordAsync() { var(connection, options) = OpenDb(); try { var employess = new List <Employee>() { new Employee { Id = Guid.NewGuid(), Number = "1", IdCardNo = "1", Name = "aaa", PrimaryDepartmentId = Guid.NewGuid(), PrimaryPositionId = Guid.NewGuid(), }, new Employee { Id = Guid.NewGuid(), Number = "2", IdCardNo = "2", Name = "aabb", PrimaryDepartmentId = Guid.NewGuid(), PrimaryPositionId = Guid.NewGuid(), }, new Employee { Id = Guid.NewGuid(), Number = "3", IdCardNo = "3", Name = "bbcc", PrimaryDepartmentId = Guid.NewGuid(), PrimaryPositionId = Guid.NewGuid(), }, }; using (var db = new ServiceDbContext(options)) { await db.Employees.AddRangeAsync(employess); await db.SaveChangesAsync(); } var target = new EmployeeAppService(statelessServiceContext, options, CreateMapper()); var result = await target.SearchByKeywordAsync("aa"); result.Count.Should().Be(2); result = await target.SearchByKeywordAsync("bb"); result.Count.Should().Be(2); } finally { connection.Close(); } }
public ListModel(EmployeeAppService _employeeAppService, IJsonSerializer jsonSerializer, IAuditLogRepository auditLogsRepo, IAuditingManager auditingManager) { employeeAppService = _employeeAppService; JsonSerializer = jsonSerializer; AuditLogsRepo = auditLogsRepo; AuditingManager = auditingManager; }
public CreateModel(IRepository <DictionaryValue, Guid> dictionaryValuesRepo, EmployeeAppService employeeAppService, IRepository <PhysicalID, int> physicalIdsRepo, DepartmentAppService departmentAppService, PositionAppService positionAppService, WorkshiftAppService workShiftsAppService) { DictionaryValuesRepo = dictionaryValuesRepo; this.employeeAppService = employeeAppService; PhysicalIdsRepo = physicalIdsRepo; this.departmentAppService = departmentAppService; this.positionAppService = positionAppService; this.workShiftsAppService = workShiftsAppService; }
public ListModel(IRepository <DictionaryValue, Guid> dictionaryValuesRepo, IWebHostEnvironment webHostEnvironment, documentAppService documentAppService, IGuidGenerator guidGenerator, EmployeeAppService employeeAppService, IJsonSerializer jsonSerializer) { DictionaryValuesRepo = dictionaryValuesRepo; this.webHostEnvironment = webHostEnvironment; this.documentAppService = documentAppService; this.guidGenerator = guidGenerator; this.employeeAppService = employeeAppService; JsonSerializer = jsonSerializer; }
public EditModel(IGuidGenerator guidGenerator, IJsonSerializer jsonSerializer, TimesheetAppService timesheetAppService, EmployeeAppService employeeAppService, IRepository <DictionaryValue, Guid> dicValuesRepo, IRepository <TimesheetWeekSummary, int> timesheetWeekSummaryRepo, IRepository <TimesheetWeekJobSummary, int> timesheetWeekJobSummaryRepo) { this.guidGenerator = guidGenerator; JsonSerializer = jsonSerializer; TimesheetAppService = timesheetAppService; EmployeeAppService = employeeAppService; DicValuesRepo = dicValuesRepo; TimesheetWeekSummaryRepo = timesheetWeekSummaryRepo; TimesheetWeekJobSummaryRepo = timesheetWeekJobSummaryRepo; }
// private readonly FilteredPagedAndSortedResultRequestDto _FPASRR; public EmployeesController(IRepository <Employee, Guid> EmpRepo, EmployeeAppService EmpAppServ, PagedAndSortedResultRequestDto PASRR, EntityDto <Guid> entityDto) { _EmpRepo = EmpRepo; _EmpAppServ = EmpAppServ; _PASRR = PASRR; _entityDto = entityDto; // _FPASRR = FPASRR; }
public ListModel(IJsonSerializer jsonSerializer, PayrunAppService payrunAppService, IRepository <PayrunDetail, int> payrunDetailsRepo, CompanyAppService CompanyAppService, EmployeeAppService employeeAppService, IRepository <DictionaryValue, Guid> dicValuesRepo, documentAppService documentAppService, TimesheetAppService timesheetAppService, IWebHostEnvironment webHostEnvironment) { JsonSerializer = jsonSerializer; PayrunAppService = payrunAppService; PayrunDetailsRepo = payrunDetailsRepo; CompanyAppService = CompanyAppService; EmployeeAppService = employeeAppService; DicValuesRepo = dicValuesRepo; this.documentAppService = documentAppService; this.timesheetAppService = timesheetAppService; this.webHostEnvironment = webHostEnvironment; }
public ActionResult Index(int id) { var employee = new EmployeeAppService().GetEmployee(id); if (employee != null) { Session["CurrentEmployee"] = employee; } else { return RedirectToAction("Index", "Employee"); } return View(employee); }
public ActionResult Index() { var model = new EmployeeViewModel(); var userSvc = new UserAppService(); var usr = userSvc.GetUserByName(HealthAuthentication.SessionInfo.UserName); var employee = usr.Employees.SingleOrDefault(); var svc = new EmployeeAppService(); var o = svc.GetEmployee(employee.EmployeeId); model.UserId = o.UserId; model.FullName = o.FullName; model.EmployeeId = o.EmployeeId; model.EMail = o.EMail; model.Phone = o.Phone; model.Mobile = o.Mobile; model.Photo = o.Photo; var blankPath = Server.MapPath("~/Content/images/Photos/blank-user.jpg"); if (!String.IsNullOrEmpty(o.Photo)) { var imagePath = Server.MapPath("~/Employee_Files/" + o.EmployeeId + "/" + o.Photo); if (!System.IO.File.Exists(imagePath)) imagePath = blankPath; byte[] image = System.IO.File.ReadAllBytes(imagePath); var base64 = Convert.ToBase64String(image); var imgSrc = String.Format("data:image/png;base64,{0}", base64); model.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-image\"/>"; } else { byte[] image = System.IO.File.ReadAllBytes(blankPath); var base64 = Convert.ToBase64String(image); var imgSrc = String.Format("data:image/png;base64,{0}", base64); model.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-image\"/>"; } return View(model); }
public JsonResult UploadPhoto() { var myFile = Request.Files[0]; var id = Request["Id"]; bool isUploaded = false; string message = "File upload failed"; if (myFile != null && myFile.ContentLength != 0) { string pathForSaving = Server.MapPath("~/Employee_Files/" + id.ToString(CultureInfo.InvariantCulture)); if (HealthHelper.CreateFolderIfNeeded(pathForSaving)) { try { var uploadFullPath = Path.Combine(pathForSaving, myFile.FileName); myFile.SaveAs(uploadFullPath); isUploaded = true; message = "File uploaded successfully!"; var extension = Path.GetExtension(Path.Combine(pathForSaving, myFile.FileName)); var fileRandom =Path.GetRandomFileName(); var fileRenamed = fileRandom.Replace(Path.GetExtension(fileRandom), "") + extension; var fullPath = Path.Combine(pathForSaving, fileRenamed); System.IO.File.Move(uploadFullPath,fullPath); var endfileRandom = Path.GetRandomFileName(); var endfileRenamed = endfileRandom.Replace(Path.GetExtension(endfileRandom), "") + extension; var endfullPath = Path.Combine(pathForSaving, endfileRenamed); ResizeImage(fullPath,endfullPath); //Resize Requires create a new file System.IO.File.Delete(fullPath); //Delete not Resized Image var svc = new EmployeeAppService(); var employee = svc.GetEmployee(Convert.ToInt32(id)); employee.Photo = endfileRenamed; svc.SaveEmployee(employee); } catch (Exception ex) { message = string.Format("File upload failed: {0}", ex.Message); } } } return Json(new { isUploaded = isUploaded, message = message }, "text/html"); }
public DataTablesResult<EmployeeViewModel> GetAllEmployees(DataTablesParam dataTableParam) { var svc = new EmployeeAppService(); var users = svc.GetAllEmployee(); var usersVm = new List<EmployeeViewModel>(); var userRoleSvc = new UserRoleAppService(); foreach (var itm in users) { var itmVm = new EmployeeViewModel { FullName = itm.FullName, UserName = itm.User.UserName, EmployeeTypeName=itm.EmployeeType.Name, Mobile = itm.Mobile, UserStateName = itm.User.UserState.Description, EMail = "<a title=\"Escribir a " + itm.FullName + "...\" target=\"_blank\" href=\"mailto:" + itm.EMail + "\"><i class=\"fa fa-envelope\"></i> " + itm.EMail + "</a>", EmployeeId = itm.EmployeeId, EmployeeTypeId = itm.EmployeeTypeId, UserId = itm.User.UserId, Phone = itm.Phone, }; var currentRoles = userRoleSvc.GetUserRoleByUserId(itm.UserId); foreach (var userRole in currentRoles) { itmVm.RoleNames += userRole.Role.Name + ","; } itmVm.RoleNames = itmVm.RoleNames.Remove(itmVm.RoleNames.Length - 1); if (!System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/"))) { Directory.CreateDirectory(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/")); } if (itm.Photo != null) { if (System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/" + itm.Photo))) { byte[] image = System.IO.File.ReadAllBytes( Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/" + itm.Photo)); var base64 = Convert.ToBase64String(image); var imgSrc = String.Format("data:image/png;base64,{0}", base64); itmVm.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-table-image\"/>"; } else { itmVm.PhotoEncodeSource = "Image Error"; } } var sb = new StringBuilder(); string editUrl = Url.Action("Edit", "Employee"); string specialtyUrl = Url.Action("Index", "MedicSpecialty"); string officeUrl = Url.Action("Index", "Office"); string scheduleUrl = Url.Action("Index", "Schedule"); sb.AppendLine("<div class=\"btn-group\">"); sb.AppendLine( "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">"); sb.AppendLine("Acciones <span class=\"caret\"></span>"); sb.AppendLine("</button>"); sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">"); sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i> Nuevo Empleado</a></li>"); sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i> Editar " + itmVm.FullName + "</a></li>"); if (itmVm.EmployeeTypeId != 2) { sb.AppendLine("<li><a href=\"" + specialtyUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i> Especialidades " + itmVm.FullName + "</a></li>"); sb.AppendLine("<li><a href=\"" + officeUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i> Oficinas de " + itmVm.FullName + "</a></li>"); sb.AppendLine("<li><a href=\"" + scheduleUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i> Agenda de " + itmVm.FullName + "</a></li>"); } sb.AppendLine("</ul>"); sb.AppendLine("</div>"); var actionButton = sb.ToString(); itmVm.ActionButton = actionButton; usersVm.Add(itmVm); } var usersVmQueryable = usersVm.AsQueryable(); return DataTablesResult.Create(usersVmQueryable, dataTableParam); }
public ActionResult Edit(EmployeeViewModel model) { if (!System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + model.EmployeeId + "/"))) { Directory.CreateDirectory(Server.MapPath("~/Employee_Files/" + model.EmployeeId + "/")); } model.EmployeeTypes = new EmployeeTypeAppService().GetAllEmployeeType(); try { var svc = new EmployeeAppService(); var o = new Employee() { UserId = model.UserId, FullName = model.FullName, EmployeeId = model.EmployeeId, EMail = model.EMail, Phone = model.Phone, EmployeeTypeId = model.EmployeeTypeId, Mobile = model.Mobile, Photo = model.Photo }; if (model.EmployeeId == -1) { o.Photo = string.Empty; svc.AddEmployee(o); ViewBag.Feed = 0; } else { o.EmployeeId = model.EmployeeId; if (model.IsDeleteAction == 0) { svc.SaveEmployee(o); } else { svc.RemoveEmployee(model.EmployeeId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } model.UserList = new UserAppService().GetAllAvailableUser(); return View(model); }
public ActionResult Edit(int id) { if (!System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + id + "/"))) { Directory.CreateDirectory(Server.MapPath("~/Employee_Files/" + id + "/")); } var model = new EmployeeViewModel(); /********************************************/ var userList = new List<User>(); var userSvc = new UserAppService(); model.EmployeeTypes = new EmployeeTypeAppService().GetAllEmployeeType(); /********************************************/ if (id != -1) { var svc = new EmployeeAppService(); var o = svc.GetEmployee(id); userList = userSvc.GetAllAvailableUserIncludeCurrent(o.UserId); model.UserId = o.UserId; model.FullName = o.FullName; model.EmployeeId = o.EmployeeId; model.EMail = o.EMail; model.Phone = o.Phone; model.Mobile = o.Mobile; model.EmployeeTypeId = o.EmployeeTypeId; model.Photo = o.Photo; var blankPath = Server.MapPath("~/Content/images/Photos/blank-user.jpg"); if (!String.IsNullOrEmpty(o.Photo) ) { var imagePath = Server.MapPath("~/Employee_Files/" + o.EmployeeId + "/" + o.Photo); if (!System.IO.File.Exists(imagePath)) imagePath = blankPath; byte[] image = System.IO.File.ReadAllBytes(imagePath); var base64 = Convert.ToBase64String(image); var imgSrc = String.Format("data:image/png;base64,{0}", base64); model.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-image\"/>"; } else { byte[] image = System.IO.File.ReadAllBytes(blankPath); var base64 = Convert.ToBase64String(image); var imgSrc = String.Format("data:image/png;base64,{0}", base64); model.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-image\"/>"; } model.UserList = userList; } else // Is New { userList = userSvc.GetAllAvailableUser(); model.UserId = -1; model.FullName = string.Empty; model.EmployeeId = -1; model.EmployeeTypeId = -1; model.EMail = string.Empty; model.Phone = string.Empty; model.Mobile = string.Empty; model.UserList = userList; } return View(model); }
public ActionResult Index(SearchViewModel model) { var ci = new CultureInfo("es-CO"); model.Specialties = new SpecialtyAppService().GetAllSpecialty(); model.Medics = new EmployeeAppService().GetAllMedics(); List<TimeSlot> lst = new TimeSlotAppService().GetAllTimeSlotWithoutAppoitment(); if (model.EmployeeId != -1) { lst = ApplyFilterEmployee(lst, model.EmployeeId); } if (model.SpecialtyId != -1) { lst = ApplyFilterSpecialty(lst, model.SpecialtyId); } if (!String.IsNullOrEmpty(model.GeoCityId) || model.GeoCityId!= "-1") { lst = ApplyFilterCity(lst, model.GeoCityId); } if (!String.IsNullOrEmpty(model.FromDate) && !String.IsNullOrEmpty(model.ToDate)) { var fromDate = DateTime.ParseExact(model.FromDate, "dd/MM/yyyy", ci); var toDate = DateTime.ParseExact(model.ToDate, "dd/MM/yyyy", ci); lst = ApplyFilterDate(lst, fromDate,toDate); } model.AvailableSlot = new List<TimeSlotViewModel>(); System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo(); foreach (var itm in lst) { var emp = new EmployeeAppService().GetEmployee(itm.Schedule.EmployeeId); var itmVm = new TimeSlotViewModel { ScheduleId = itm.ScheduleId, MonthName = itm.Schedule.Month, TimeSlotId = itm.TimeSlotId, OfficeId = itm.OfficeId, Day = itm.Day, StartTime = itm.StartTime, EndTime = itm.EndTime, StartTimeText = itm.StartTime.ToShortTimeString(), EndTimeText = itm.EndTime.ToShortTimeString(), OfficeAddress = string.Format("Medico:{0}({1}) {2},{3}", emp.FullName, itm.Office.Address, itm.Office.Number, itm.Office.GeoCity.Name), DayName = string.Format("{0},{1} de {2} de {3}", new DateTime(itm.Schedule.Year, itm.Schedule.Month, itm.Day).DayOfWeek.ToString(ci), itm.Day,mfi.GetMonthName(itm.Schedule.Month).ToString(),itm.Schedule.Year) }; model.AvailableSlot.Add(itmVm); } Session["AvailableSchedule"] = model.AvailableSlot; return View(model); }
public async Task Test_GetByIdAsync_GetByUserIdAsync() { var(connection, options) = OpenDb(); try { var dep0 = new Department { Id = Guid.NewGuid(), Number = "0", Name = "sclq", }; var dep1 = new Department { Id = Guid.NewGuid(), ParentId = dep0.Id, Number = "1", Name = "sclq-jt", }; var pos1 = new Position { DepartmentId = dep1.Id, Id = Guid.NewGuid(), Name = "gm" }; var dep2 = new Department { Id = Guid.NewGuid(), ParentId = dep0.Id, Number = "2", Name = "sclq-gs" }; var pos2 = new Position { DepartmentId = dep2.Id, Id = Guid.NewGuid(), Name = "ceo" }; var emp1 = new Employee { Id = Guid.NewGuid(), UserId = Guid.NewGuid(), Number = "1", IdCardNo = "1", Name = "aaa", PrimaryDepartmentId = dep1.Id, PrimaryPositionId = pos1.Id, }; emp1.Positions = new List <EmployeePosition> { new EmployeePosition { EmployeeId = emp1.Id, PositionId = pos1.Id, IsPrimary = true }, new EmployeePosition { EmployeeId = emp1.Id, PositionId = pos2.Id, IsPrimary = false, }, }; using (var db = new ServiceDbContext(options)) { await db.Departments.AddRangeAsync(dep0, dep1, dep2); await db.Positions.AddRangeAsync(pos1, pos2); await db.Employees.AddRangeAsync(emp1); await db.SaveChangesAsync(); } var target = new EmployeeAppService(statelessServiceContext, options, CreateMapper()); var result = await target.GetByIdAsync(emp1.Id); result.Name.Should().Be("aaa"); result.ParttimePositionIds.Count.Should().Be(1); result.ParttimePositionIds[0].Should().Be(pos2.Id); result = await target.GetByUserIdAsync(emp1.UserId.Value); result.Name.Should().Be("aaa"); } finally { connection.Close(); } }
public ActionResult Index(EmployeeViewModel model) { var userSvc = new UserAppService(); var usr = userSvc.GetUserByName(HealthAuthentication.SessionInfo.UserName); var employee = usr.Employees.SingleOrDefault(); try { var svc = new EmployeeAppService(); var o = svc.GetEmployee(model.EmployeeId); o.EmployeeId = employee.EmployeeId; o.FullName = model.FullName; o.EmployeeId = model.EmployeeId; o.EMail = model.EMail; o.Phone = model.Phone; o.Mobile = model.Mobile; o.Photo = model.Photo; svc.SaveEmployee(o); ViewBag.Feed = 0; } catch (Exception) { ViewBag.Feed = 1; } return View(model); }
public async Task GetUserIdsByDepartmentIdAsync() { var(connection, options) = OpenDb(); try { var dep1 = new Department { Id = Guid.NewGuid(), Number = "1", Name = "sclq", }; var pos1 = new Position { DepartmentId = dep1.Id, Id = Guid.NewGuid(), Name = "ceo" }; var pos2 = new Position { DepartmentId = dep1.Id, Id = Guid.NewGuid(), Name = "gm" }; var emp1 = new Employee { Id = Guid.NewGuid(), Number = "1", IdCardNo = "1", Name = "aaa", PrimaryDepartmentId = dep1.Id, PrimaryPositionId = pos1.Id, }; emp1.Positions = new List <EmployeePosition> { new EmployeePosition { EmployeeId = emp1.Id, PositionId = pos1.Id, IsPrimary = true }, }; var emp2 = new Employee { Id = Guid.NewGuid(), Number = "2", IdCardNo = "2", Name = "bbb", PrimaryDepartmentId = dep1.Id, PrimaryPositionId = pos2.Id, }; emp2.Positions = new List <EmployeePosition> { new EmployeePosition { EmployeeId = emp2.Id, PositionId = pos2.Id, IsPrimary = true } }; using (var db = new ServiceDbContext(options)) { await db.Departments.AddRangeAsync(dep1); await db.Positions.AddRangeAsync(pos1, pos2); await db.Employees.AddRangeAsync(emp1, emp2); await db.SaveChangesAsync(); } var target = new EmployeeAppService(statelessServiceContext, options, CreateMapper()); var result = await target.GetUserIdsByDepartmentIdAsync(dep1.Id); result.Count.Should().Be(0); emp1.UserId = Guid.NewGuid(); emp2.UserId = Guid.NewGuid(); using (var db = new ServiceDbContext(options)) { db.Employees.UpdateRange(emp1, emp2); await db.SaveChangesAsync(); } result = await target.GetUserIdsByDepartmentIdAsync(dep1.Id); result.Count.Should().Be(2); } finally { connection.Close(); } }
public static List<Employee> GetAllEmployeeList() { var svc = new EmployeeAppService(); return svc.GetAllEmployee(); }
public ActionResult Edit(EmployeeViewModel model) { try { var svc = new EmployeeAppService(); var o = new Employee() { UserId = model.UserId, FullName = model.FullName, EmployeeId = model.EmployeeId, EMail = model.EMail, Phone = model.Phone, Mobile = model.Mobile, Photo = model.Photo }; if (model.EmployeeId == -1) { svc.AddEmployee(o); ViewBag.Feed = 0; } else { o.EmployeeId = model.EmployeeId; if (model.IsDeleteAction == 0) { svc.SaveEmployee(o); } else { svc.RemoveEmployee(model.EmployeeId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } model.UserList = new UserAppService().GetAllAvailableUser(); return View(model); }