/// <summary> /// Users the facilities. /// </summary> /// <param name="userRoles">The user roles.</param> /// <returns></returns> public string UserFacilities(IEnumerable <UserRole> userRoles) { var facilityNames = string.Empty; var ids = new List <int>(); foreach (var item in userRoles) { if (item.Role != null) { foreach (var f in item.Role.FacilityRole.ToList()) { if (ids.All(fac => fac != f.FacilityId)) { ids.Add(f.FacilityId); using (var facBal = new FacilityBal()) { if (string.IsNullOrEmpty(facilityNames)) { facilityNames = facBal.GetFacilityNameById(f.FacilityId); } else { facilityNames += string.Format(", {0}", facBal.GetFacilityNameById(f.FacilityId)); } } } } } } return(facilityNames); }
/// <summary> /// Gets the facility structure bread crumbs. /// </summary> /// <param name="facilityStructureId"> /// The facility structure identifier. /// </param> /// <param name="facilityid"> /// The facilityid. /// </param> /// <param name="ParentId"> /// The parent identifier. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public string GetFacilityStructureBreadCrumbs(int facilityStructureId, string facilityid, string ParentId) { var _facilityStructureId = string.Empty; using (var facilityBal = new FacilityBal()) { _facilityStructureId = facilityBal.GetFacilityNameById(Convert.ToInt32(facilityid)); } switch (facilityStructureId) { case 82: _facilityStructureId += " : " + "Floor"; break; case 83: _facilityStructureId += " : " + "Department"; break; case 84: _facilityStructureId += " : " + "Room"; break; case 85: _facilityStructureId += " : " + "Bed"; break; } return(_facilityStructureId); }
/// <summary> /// Gets the facility role list custom. /// </summary> /// <param name="corporateId">The corporate identifier.</param> /// <param name="facilityId">The facility identifier.</param> /// <param name="roleId">The role identifier.</param> /// <returns></returns> public List <FacilityRoleCustomModel> GetFacilityRoleListCustom(int corporateId, int facilityId, int roleId) { var list = new List <FacilityRoleCustomModel>(); using (var rep = UnitOfWork.FacilityRoleRepository) { var facilityRoleList = corporateId > 0 ? (facilityId == 0 ? rep.Where(fr => !fr.IsDeleted && fr.IsActive && fr.CorporateId == corporateId).ToList() : rep.Where(fr => !fr.IsDeleted && fr.IsActive && fr.CorporateId == corporateId && fr.FacilityId == facilityId).ToList()) : rep.Where(fr => !fr.IsDeleted && fr.IsActive).ToList(); if (roleId > 0) { facilityRoleList = facilityRoleList.Where(r => r.RoleId == roleId).ToList(); } using (var facBal = new FacilityBal()) { using (var corpBal = new CorporateBal()) { using (var roleBal = new RoleBal()) { list.AddRange(facilityRoleList.Select(item => new FacilityRoleCustomModel { FacilityRoleId = item.FacilityRoleId, FacilityId = item.FacilityId, RoleId = item.RoleId, CorporateId = item.CorporateId, CreatedBy = item.CreatedBy, CreatedDate = item.CreatedDate, ModifiedBy = item.ModifiedBy, ModifiedDate = item.ModifiedDate, IsDeleted = item.IsDeleted, DeletedBy = item.DeletedBy, DeletedDate = item.DeletedDate, IsActive = item.IsActive, FacilityName = facBal.GetFacilityNameById(item.FacilityId), CorporateName = corpBal.GetCorporateNameById(item.CorporateId), RoleName = roleBal.GetRoleNameById(item.RoleId) })); } } } list = list.GroupBy(x => new { x.RoleName, x.FacilityId }).Select(x => x.FirstOrDefault()).ToList(); return(list.OrderBy(x => x.RoleName).ToList()); } }