//get all references by organization public List <AccreditationsModel> GetAccreditation(Guid organization, int?userId = null, int rows = 10, int page = 0, int min = 0, int max = 0, int state = 1000, string language = "en-US") { try { List <AccreditationsModel> ListAccreditation = new List <AccreditationsModel>(); var result = AccreditationsComponent.GetAccreditationId(organization).ToList().OrderBy(x => x.OrganizationId); var totalCount = result.Count(); var totalPages = (int)Math.Ceiling((double)totalCount / rows); var prevLink = page > 0 ? string.Format("/Accreditations/GetAccreditation?rows={0}&page={1}", rows, page - 1) : ""; var nextLink = page < totalPages - 1 ? string.Format("/Accreditations/GetAccreditation?rows={0}&page={1}", rows, page + 1) : ""; foreach (var resultTmp in result.Skip(rows * page).Take(rows).ToList()) { ListAccreditation.Add(new AccreditationsModel() { AccreditationId = (Guid)resultTmp.AccreditationId, OrganizationId = (Guid)resultTmp.OrganizationId, Content = resultTmp.Content, Description = resultTmp.Description, DocumentId = (Guid)resultTmp.DocumentId, Name = resultTmp.Name, Type = resultTmp.Type }); } return(ListAccreditation); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public List <OrganizationsModel> GetOrganization(Guid organization, int?userId = -1, string language = "en-US") { try { var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); //lists List <OrganizationsModel> ListOrganization = new List <OrganizationsModel>(); List <string> ListLogo = new List <string>(); List <ReferencesModel> ListReference = new List <ReferencesModel>(); List <AccreditationsModel> ListAccreditation = new List <AccreditationsModel>(); List <AttributesModel> ListAttributes = new List <AttributesModel>(); List <UserProfileModel> ListuserInfo = new List <UserProfileModel>(); //get attributes var attributes = AttributesComponent.GetAttributesList(organization).ToList(); foreach (var item in attributes) { ListAttributes.Add(new AttributesModel() { AttributeID = item.AttributeID, OrganizationID = item.OrganizationID, Type = item.Type, Value = item.Value, ValueType = item.ValueType, Description = item.Description, Label = item.Label }); } //get number of solution var solutionsNumber = SolutionComponent.GetSolutionPerOrganization(organization).ToList().Count(); //get partners var partnersLogo = PartnershipsComponent.GetPartnershipListLogo(organization).ToList(); //get organizations by Id var List = OrganizationComponent.GetOrganizationPerId(organization).ToList(); //get organization references by Id var resultReferences = ReferencesComponent.GetReferences(organization).ToList(); //get user info var users = List.First().UserOrganizations.Where(a => a.Role == 1); //know if current user is owner bool owner = false; if (currentUser.UserID == users.First().UserID || currentUser.IsInRole("Administrators") || currentUser.IsSuperUser) { owner = true; } var userProfile = new UserPropertyComponent(users.First().UserID); // UserProfileModel userProfile = user.GetProfile(Convert.ToInt32(List.First().CreatedBy)); string finalExt = ""; if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png"))) { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png"; } else if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg"))) { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg"; } else { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\defaultImage.png"; } if (resultReferences.Count() > 0) { foreach (var item in resultReferences) { var userProfileReferences = new UserPropertyComponent(item.UserId); ListReference.Add(new ReferencesModel() { ReferenceId = (Guid)item.ReferenceId, OrganizationId = (Guid)item.OrganizationId, UserId = item.UserId, Type = item.Type, Comment = item.Comment, Created = item.Created.ToString(), Updated = item.Updated.ToString(), Deleted = item.Deleted, fullName = userProfileReferences.UserProperty.FirstName + " " + userProfileReferences.UserProperty.LastName }); } } //Get organization accreditations var resultAccreditations = AccreditationsComponent.GetAccreditationId(organization).ToList(); if (resultAccreditations.Count() > 0) { foreach (var item in resultAccreditations) { DocumentComponent doc = new DocumentComponent((Guid)item.DocumentId); ListAccreditation.Add(new AccreditationsModel() { AccreditationId = (Guid)item.AccreditationId, OrganizationId = (Guid)item.OrganizationId, Content = item.Content, Description = item.Description, DocumentId = (Guid)item.DocumentId, Name = item.Name, Type = item.Type, yearAccreditation = item.Year, docName = doc.Document.Name, docUrl = "" }); } } foreach (var item in List) { ListOrganization.Add(new OrganizationsModel() { OrganizationID = (Guid)item.OrganizationID, Code = item.Code, Name = item.Name, //Address = currentUser.IsInRole("NexsoUser") ? item.Address : "", Address = item.Address, //Phone = currentUser.IsInRole("NexsoUser") ? item.Phone : "", Phone = item.Phone, //Email = currentUser.IsInRole("NexsoUser") ? item.Email : "", Email = item.Email, //ContactEmail = currentUser.IsInRole("NexsoUser") ? item.ContactEmail : "", ContactEmail = item.ContactEmail, Website = item.Website, Twitter = item.Twitter, //Skype = currentUser.IsInRole("NexsoUser") ? item.Skype : "", Skype = item.Skype, //Facebook = currentUser.IsInRole("NexsoUser") ? item.Facebook : "", Facebook = item.Facebook, GooglePlus = item.GooglePlus, LinkedIn = item.LinkedIn, Description = item.Description, Logo = item.Logo, Country = item.Country, Region = item.Region, City = item.City, ZipCode = item.ZipCode, Created = Convert.ToDateTime(item.Created), Updated = Convert.ToDateTime(item.Updated), Latitude = Convert.ToDecimal(item.Latitude), Longitude = Convert.ToDecimal(item.Longitude), GoogleLocation = item.GoogleLocation, Language = item.Language, Year = Convert.ToInt32(item.Year), Staff = Convert.ToInt32(item.Staff), Budget = Convert.ToDecimal(item.Budget), CheckedBy = item.CheckedBy, CreatedOn = Convert.ToDateTime(item.Created), UpdatedOn = Convert.ToDateTime(item.Updated), CreatedBy = Convert.ToInt32(item.CreatedBy), Deleted = Convert.ToBoolean(item.Deleted), accreditations = ListAccreditation, references = ListReference, solutionNumber = Convert.ToInt32(solutionsNumber), partnershipsLogo = partnersLogo, attributes = ListAttributes, userFirstName = userProfile.UserProperty.FirstName, userLastName = userProfile.UserProperty.LastName, userEmail = userProfile.UserProperty.email, userLinkedIn = userProfile.UserProperty.LinkedIn, userFacebook = userProfile.UserProperty.FaceBook, userTwitter = userProfile.UserProperty.Twitter, userAddress = userProfile.UserProperty.Address, userCity = userProfile.UserProperty.City, userCountry = userProfile.UserProperty.Country, userProfilePicture = finalExt, userID = currentUser.UserID.ToString(), ownerSolution = owner }); } return(ListOrganization); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
//get organization list public List <OrganizationsModel> GetList(int?userId = -1, int rows = 10, int page = 0, int min = 0, int max = 0, int state = 1000, string language = "en-US") { try { var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); //lists List <OrganizationsModel> ListOrganization = new List <OrganizationsModel>(); List <ReferencesModel> ListReference = new List <ReferencesModel>(); List <AccreditationsModel> ListAccreditation = new List <AccreditationsModel>(); //Get all Organizations var result = OrganizationComponent.GetOrganizations().OrderBy(x => x.Name); var totalCount = result.Count(); var totalPages = (int)Math.Ceiling((double)totalCount / rows); var prevLink = page > 0 ? string.Format("/Organizations/GetList?rows={0}&page={1}", rows, page - 1) : ""; var nextLink = page < totalPages - 1 ? string.Format("/Organizations/GetList?rows={0}&page={1}", rows, page + 1) : ""; foreach (var resultTmp in result.Skip(rows * page).Take(rows).ToList()) { List <Organization> organizationList = OrganizationComponent.GetOrganizationPerId(resultTmp.OrganizationID); //Get Organization references by Id var resultReferences = ReferencesComponent.GetReferences(resultTmp.OrganizationID).ToList(); if (resultReferences.Count() > 0) { foreach (var item in resultReferences) { ListReference.Add(new ReferencesModel() { ReferenceId = (Guid)item.ReferenceId, OrganizationId = (Guid)item.OrganizationId, UserId = item.UserId, Type = item.Type, Comment = item.Comment, Created = item.Created.ToString(), Updated = item.Updated.ToString(), Deleted = item.Deleted }); } } //Get Organization Accreditations var resultAccreditations = AccreditationsComponent.GetAccreditationId(resultTmp.OrganizationID).ToList(); if (resultAccreditations.Count() > 0) { foreach (var item in resultAccreditations) { ListAccreditation.Add(new AccreditationsModel() { AccreditationId = (Guid)item.AccreditationId, OrganizationId = (Guid)item.OrganizationId, Content = item.Content, Description = item.Description, DocumentId = (Guid)item.DocumentId, Name = item.Name, Type = item.Type }); } } foreach (var item in organizationList) { ListOrganization.Add(new OrganizationsModel() { OrganizationID = (Guid)item.OrganizationID, Code = item.Code, Name = item.Name, //Address = currentUser.IsInRole("NexsoUser") ? item.Address : "", Address = item.Address, //Phone = currentUser.IsInRole("NexsoUser") ? item.Phone : "", Phone = item.Phone, //Email = currentUser.IsInRole("NexsoUser") ? item.Email : "", Email = item.Email, //ContactEmail = currentUser.IsInRole("NexsoUser") ? item.ContactEmail : "", ContactEmail = item.ContactEmail, Website = item.Website, Twitter = item.Twitter, //Skype = currentUser.IsInRole("NexsoUser") ? item.Skype : "", Skype = item.Skype, //Facebook = currentUser.IsInRole("NexsoUser") ? item.Facebook : "", Facebook = item.Facebook, GooglePlus = item.GooglePlus, LinkedIn = item.LinkedIn, Description = item.Description, Logo = item.Logo, Country = item.Country, Region = item.Region, City = item.City, ZipCode = item.ZipCode, Created = Convert.ToDateTime(item.Created), Updated = Convert.ToDateTime(item.Updated), Latitude = Convert.ToDecimal(item.Latitude), Longitude = Convert.ToDecimal(item.Longitude), GoogleLocation = item.GoogleLocation, Language = item.Language, Year = Convert.ToInt32(item.Year), Staff = Convert.ToInt32(item.Staff), Budget = Convert.ToDecimal(item.Budget), CheckedBy = item.CheckedBy, CreatedOn = Convert.ToDateTime(item.Created), UpdatedOn = Convert.ToDateTime(item.Updated), CreatedBy = Convert.ToInt32(item.CreatedBy), Deleted = Convert.ToBoolean(item.Deleted), accreditations = ListAccreditation, references = ListReference }); } } var paginationHeader = new { TotalCount = totalCount, TotalPages = totalPages, PrevPageLink = prevLink, NextPageLink = nextLink }; System.Web.HttpContext.Current.Response.Headers.Add("X-Pagination", Newtonsoft.Json.JsonConvert.SerializeObject(paginationHeader)); return(ListOrganization); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }