public string GetOrganizationID(string SessionID) { //using (var dataContext = new WorkersInMotionDB()) //{ // string UserGUID = (from p in dataContext.MasterLogins // where p.SessionID == SessionID // select p).SingleOrDefault().UserGUID.ToString(); // if (!string.IsNullOrEmpty(UserGUID)) // { // return (from p in dataContext.OrganizationUsersMaps // where p.UserGUID == new Guid(UserGUID) // select p).SingleOrDefault().OrganizationGUID.ToString(); // } // else // { // return ""; // } //} SqlParameter[] Param = new SqlParameter[1]; Param[0] = new SqlParameter("@pSessionID", SqlDbType.NVarChar, -1); Param[0].Value = SessionID; OrganizationUsersMap mOrganizationUsersMap = context.Database.SqlQuery <OrganizationUsersMap>("Select * from OrganizationUsersMap where UserGUID in (Select UserGUID from MasterLogins where SessionID=@pSessionID)", Param).FirstOrDefault(); if (mOrganizationUsersMap != null) { return(mOrganizationUsersMap.OrganizationGUID.ToString()); } else { return(string.Empty); } }
public int UpdateOrganizationUserMap(OrganizationUsersMap OrganizationUsersMap) { //context.Entry(organizationUserMap).State = EntityState.Modified; SqlParameter[] Param = new SqlParameter[15]; Param[0] = new SqlParameter("@pOrganizationUserMapGUID", SqlDbType.UniqueIdentifier); Param[0].Value = OrganizationUsersMap.OrganizationUserMapGUID; Param[1] = new SqlParameter("@pOrganizationGUID", SqlDbType.UniqueIdentifier); Param[1].Value = OrganizationUsersMap.OrganizationGUID; Param[2] = new SqlParameter("@pUserGUID", SqlDbType.UniqueIdentifier); Param[2].Value = OrganizationUsersMap.UserGUID; Param[3] = new SqlParameter("@pIsContractor", SqlDbType.Bit); Param[3].Value = OrganizationUsersMap.IsContractor; Param[4] = new SqlParameter("@pIsActive", SqlDbType.Bit); Param[4].Value = (object)OrganizationUsersMap.IsActive ?? DBNull.Value; Param[5] = new SqlParameter("@pStatus", SqlDbType.SmallInt); Param[5].Value = OrganizationUsersMap.Status; Param[6] = new SqlParameter("@pHourlyRate", SqlDbType.Float); Param[6].Value = (object)OrganizationUsersMap.HourlyRate ?? DBNull.Value; Param[7] = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier); Param[7].Value = (object)OrganizationUsersMap.RegionGUID ?? DBNull.Value; Param[8] = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier); Param[8].Value = (object)OrganizationUsersMap.TerritoryGUID ?? DBNull.Value; Param[9] = new SqlParameter("@pUserType", SqlDbType.NVarChar, 10); Param[9].Value = (object)OrganizationUsersMap.UserType ?? DBNull.Value; Param[10] = new SqlParameter("@pUserSubTypeCode", SqlDbType.NVarChar, 10); Param[10].Value = (object)OrganizationUsersMap.UserSubTypeCode ?? DBNull.Value; Param[11] = new SqlParameter("@pCreateDate", SqlDbType.DateTime); Param[11].Value = (object)OrganizationUsersMap.CreateDate ?? DBNull.Value; Param[12] = new SqlParameter("@pCreateBy", SqlDbType.UniqueIdentifier); Param[12].Value = (object)OrganizationUsersMap.CreateBy ?? DBNull.Value; Param[13] = new SqlParameter("@pLastModifiedDate", SqlDbType.DateTime); Param[13].Value = (object)OrganizationUsersMap.LastModifiedDate ?? DBNull.Value; Param[14] = new SqlParameter("@pLastModifiedBy", SqlDbType.UniqueIdentifier); Param[14].Value = (object)OrganizationUsersMap.LastModifiedBy ?? DBNull.Value; return(context.Database.ExecuteSqlCommand("Update OrganizationUsersMap set OrganizationGUID=@pOrganizationGUID," + "UserGUID=@pUserGUID,IsContractor=@pIsContractor,IsActive=@pIsActive,Status=@pStatus,HourlyRate=@pHourlyRate,RegionGUID=@pRegionGUID," + "TerritoryGUID=@pTerritoryGUID,UserType=@pUserType,UserSubTypeCode=@pUserSubTypeCode," + "CreateDate=@pCreateDate,CreateBy=@pCreateBy,LastModifiedDate=@pLastModifiedDate,LastModifiedBy=@pLastModifiedBy where OrganizationUserMapGUID=@pOrganizationUserMapGUID", Param)); }
// // GET: /JobStatus/ public ActionResult Index(string FromDate = "", string ToDate = "", string regionguid = "", string territoryguid = "", string jobindexguid = "", string Date = "", string selection = "", string ponumber = "") { Logger.Debug("Inside AssignJob Controller- Index"); try { if (Session["OrganizationGUID"] != null) { if (!string.IsNullOrEmpty(Date)) { ViewBag.DateValue = HttpUtility.HtmlDecode(Date); } var jobStatus = new JobStatusViewModel(); jobStatus.JobStatusModel = new List <JobStatusModel>(); var jobGroup = new List <Job>(); //Job ljob = new Job(); OrganizationUsersMap pOrganizationUsersMap = _IUserRepository.GetUserByID(new Guid(Session["UserGUID"].ToString())); Logger.Debug("USerGUID:" + Session["UserGUID"].ToString()); if (pOrganizationUsersMap != null) { StringBuilder sb = new StringBuilder(); sb.Append("<div class='actions'>"); sb.Append("<div class='btn-group'>"); if (!string.IsNullOrEmpty(territoryguid)) { Logger.Debug("Inside TerritoryGUID" + territoryguid.ToString()); sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(territoryguid)) + " <i class='icon-angle-down'></i></a>"); } else { if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U") { if (!string.IsNullOrEmpty(selection) && selection == "All") { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> All <i class='icon-angle-down'></i></a>"); } else { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> Select Market <i class='icon-angle-down'></i></a>"); } } else if (pOrganizationUsersMap != null) { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(pOrganizationUsersMap.TerritoryGUID.ToString())) + " <i class='icon-angle-down'></i></a>"); } } sb.Append("<ul id='ulworkgroup' class='dropdown-menu pull-right'>"); if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U" && pOrganizationUsersMap != null) { if (string.IsNullOrEmpty(selection) || selection != "All") { sb.Append("<li><a href=" + Url.Action("Index", "JobStatus", new { selection = "All" }) + ">All</a></li>"); } List <Territory> TerritoryList = new List <Territory>(); if (Session["UserType"].ToString() == "ENT_A") { Logger.Debug("Inside OrganizationGUID" + pOrganizationUsersMap.OrganizationGUID.ToString()); TerritoryList = _ITerritoryRepository.GetTerritoryByOrganizationGUID(new Guid(pOrganizationUsersMap.OrganizationGUID.ToString())).ToList(); } else { if (pOrganizationUsersMap.RegionGUID != null) { Logger.Debug("Inside RegionGUID" + pOrganizationUsersMap.RegionGUID.ToString()); TerritoryList = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(pOrganizationUsersMap.RegionGUID.ToString())).ToList(); } } if (TerritoryList != null && TerritoryList.Count > 0) { foreach (Territory item in TerritoryList) { sb.Append("<li><a href=" + Url.Action("Index", "JobStatus", new { territoryguid = item.TerritoryGUID.ToString(), regionguid = item.RegionGUID.ToString() }) + " data-groupguid=" + item.TerritoryGUID + ">" + item.Name + "</a></li>"); Logger.Debug("Inside Territory foreach"); } } } sb.Append("</ul>"); sb.Append("</div>"); sb.Append("</div>"); ViewBag.RegionList = sb.ToString(); Job mjob = new Job(); if (!string.IsNullOrEmpty(ponumber)) { mjob.PONumber = ponumber; TempData["PoNumber"] = ponumber; } if (!string.IsNullOrEmpty(FromDate) && !string.IsNullOrEmpty(ToDate)) { //ViewBag.FromDate = FromDate; //ViewBag.ToDate = ToDate; if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U") { mjob.ActualStartTime = Convert.ToDateTime(FromDate); // mjob.PreferedStartTime = _IUserRepository.GetLocalDateTime(mjob.PreferedStartTime, Session["TimeZoneID"].ToString()); mjob.ActualEndTime = Convert.ToDateTime(ToDate); // mjob.PreferedEndTime = _IUserRepository.GetLocalDateTime(mjob.PreferedEndTime, Session["TimeZoneID"].ToString()); mjob.TerritoryGUID = pOrganizationUsersMap.TerritoryGUID; mjob.RegionGUID = pOrganizationUsersMap.RegionGUID; mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { mjob.ActualStartTime = Convert.ToDateTime(FromDate); // mjob.PreferedStartTime = _IUserRepository.GetLocalDateTime(mjob.PreferedStartTime, Session["TimeZoneID"].ToString()); mjob.ActualEndTime = Convert.ToDateTime(ToDate); // mjob.PreferedEndTime = _IUserRepository.GetLocalDateTime(mjob.PreferedEndTime, Session["TimeZoneID"].ToString()); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } } else if (!string.IsNullOrEmpty(regionguid) && !string.IsNullOrEmpty(territoryguid)) { mjob.ActualStartTime = DateTime.Now.AddDays(-29); mjob.ActualEndTime = DateTime.Now; mjob.RegionGUID = new Guid(regionguid); mjob.TerritoryGUID = new Guid(territoryguid); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { mjob.ActualStartTime = DateTime.Now.AddDays(-29); mjob.ActualEndTime = DateTime.Now; if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U") { mjob.RegionGUID = pOrganizationUsersMap.RegionGUID; mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } //if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U") //{ // jobGroup = _IJobRepository.GetjobStatusByRegionAndTerritory(new Guid(Session["UserGUID"].ToString())).ToList(); //} //else //{ // ljob.AssignedUserGUID = new Guid(Session["UserGUID"].ToString()); // ljob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); // ljob.IsDeleted = false; // jobGroup = _IJobRepository.GetJobStatus(ljob).ToList(); //} } if (jobGroup != null && jobGroup.Count > 0) { foreach (var job in jobGroup.ToList()) { JobStatusModel js = new JobStatusModel(); js.JobName = job.JobName; js.JobIndexGUID = job.JobGUID.ToString(); // js.JobLogicalID = job.JobFormGUID.ToString(); js.UserGUID = job.AssignedUserGUID.ToString(); js.PreferredStartTime = job.PreferedStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : job.PreferedStartTime.ToString() : ""; js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? _IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : ""; js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? Convert.ToDateTime(js.PreferredStartTime).ToString("MM/dd/yy HH:mm") : ""; js.PreferredEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : job.PreferedEndTime.ToString() : ""; js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? _IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : ""; js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? Convert.ToDateTime(js.PreferredEndTime).ToString("MM/dd/yy HH:mm") : ""; js.ActualStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : ""; js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : ""; js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? Convert.ToDateTime(js.ActualStartTime).ToString("MM/dd/yy HH:mm") : ""; js.ActualEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : job.ActualEndTime.ToString() : ""; js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? _IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : ""; js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? Convert.ToDateTime(js.ActualEndTime).ToString("MM/dd/yy HH:mm") : ""; js.LastModifiedDate = job.PreferedEndTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : job.LastModifiedDate.ToString() : ""; js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? _IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : ""; js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? Convert.ToDateTime(js.LastModifiedDate).ToString("MM/dd/yy HH:mm") : ""; // ActualStartTime = job.ActualStartTime.ToString() != "" ? Convert.ToDateTime(job.ActualStartTime).ToString("yyyy/MM/dd HH:mm") : "",//, Session["TimeZoneID"].ToString() js.EstimatedStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null?_IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : ""; js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : ""; js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? Convert.ToDateTime(js.EstimatedStartTime).ToString("MM/dd/yy HH:mm") : ""; //js.AssignedTo = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())) != null ? _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())).UserName : ""; js.EstimatedDuration = Convert.ToDouble(job.EstimatedDuration); js.Status = _IJobRepository.GetStatusName(Convert.ToInt32(job.StatusCode)); // js.CustomerName = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? GetCompanyName(new Guid(job.CustomerGUID.ToString())) : ""; js.CustomerName = job.CustomerGUID != null?GetCompanyName(job.CustomerGUID) : GetCompanyNameByPO(job.PONumber); js.StoreID = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? getStoreID(job.CustomerStopGUID.ToString()) : ""; js.PONumber = job.PONumber; js.statuscode = job.StatusCode != null?Convert.ToInt32(job.StatusCode) : 0; js.RegionGUID = job.RegionGUID != null?job.RegionGUID.ToString() : ""; js.TerritoryGUID = job.TerritoryGUID != null?job.TerritoryGUID.ToString() : ""; js.SiteAddress = job.ServiceAddress; JobProgress pJobProgress = _IJobRepository.GetJobProgressMismatch(job.JobGUID, js.statuscode); bool mismatch; if (pJobProgress != null && bool.TryParse(pJobProgress.LocationMismatch.ToString(), out mismatch)) { js.locationmismatch = mismatch; } if (job.StatusCode >= 2 && job.AssignedUserGUID != null) { js.Email = GetEmails(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID); js.AssociateContactNumber = GetContactNumber(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID); GlobalUser _globaluser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())); if (_globaluser != null) { js.AssociateName = _globaluser.UserName; js.AssignedTo = _globaluser.UserName; } else { js.AssignedTo = ""; js.AssociateName = ""; } } else { js.Email = ""; js.AssignedTo = ""; js.AssociateName = ""; js.AssociateContactNumber = ""; } //js.GroupName = _IJobRepository.GetGroupName(job.GroupCode); if (job.CustomerStopGUID != null && job.CustomerStopGUID != Guid.Empty) { Market _Market = _IMarketRepository.GetMarketByID(new Guid(job.CustomerStopGUID.ToString())); if (_Market != null) { if (!string.IsNullOrEmpty(_Market.RMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID); if (_userprofile != null) { js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.RegionalManager = ""; } } } else { js.RegionalManager = ""; } if (!string.IsNullOrEmpty(_Market.FMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.FMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, pOrganizationUsersMap.OrganizationGUID); if (_userprofile != null) { js.FieldManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.FieldManager = ""; } } } else { js.FieldManager = ""; } } else { js.RegionalManager = ""; js.FieldManager = ""; } } else if (!string.IsNullOrEmpty(job.PONumber)) { POs _po = _IPORepository.GetPObyPoNumber(job.PONumber); if (_po != null) { Market _Market = _IMarketRepository.GetMarketByCustomerID(job.OrganizationGUID, _po.PlaceID, _po.MarketID); if (_Market != null) { if (!string.IsNullOrEmpty(_Market.RMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID); if (_userprofile != null) { js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.RegionalManager = ""; } } } else { js.RegionalManager = ""; } if (!string.IsNullOrEmpty(_Market.FMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.FMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID); if (_userprofile != null) { js.FieldManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.FieldManager = ""; } } } else { js.FieldManager = ""; } } else { js.RegionalManager = ""; js.FieldManager = ""; } } else { js.RegionalManager = ""; js.FieldManager = ""; } } else { js.RegionalManager = ""; js.FieldManager = ""; } jobStatus.JobStatusModel.Add(js); } } if (!string.IsNullOrEmpty(regionguid) && !string.IsNullOrEmpty(territoryguid) && !string.IsNullOrEmpty(jobindexguid)) { IList <GlobalUser> _GlobalUser = _IGlobalUserRepository.GetGlobalUserByRegionandTerritory(new Guid(regionguid), new Guid(territoryguid)).ToList(); jobStatus.GlobalUsers = new List <GlobalUserModel>(); foreach (var user in _GlobalUser.ToList()) { jobStatus.GlobalUsers.Add(new GlobalUserModel { UserGUID = user.UserGUID, UserName = user.UserName }); } if (!string.IsNullOrEmpty(jobindexguid)) { jobStatus.JobModel = new JobModel(); jobStatus.JobModel.JobName = _IJobRepository.GetJobByID(new Guid(jobindexguid)).JobName; jobStatus.JobModel.JobIndexGUID = new Guid(jobindexguid); } } } return(View(jobStatus)); } else { //TempData["msg"] = "<script>ModalPopupsAlert('Workers-In-Motion','Session Expired');</script>"; //return RedirectToAction("../User/Login"); return(RedirectToAction("SessionTimeOut", "User")); } } catch (Exception ex) { Logger.Error(ex.Message); return(RedirectToAction("Login", "User")); } }
//public UserController(WorkersInMotionJobContext context) //{ // // this._IJobRepository = new JobRepository(context); //} #endregion public ActionResult Index(string id = "", string regionguid = "", string selection = "") { Logger.Debug("Inside User Controller- Index"); try { if (Session["OrganizationGUID"] != null) { if (!string.IsNullOrEmpty(id)) { TempData["TabName"] = id; } else { TempData["TabName"] = "Details"; } mycompany pmycompany = new mycompany(); pmycompany.OrganizationEditView = new OrganizationEditView(); pmycompany.AspNetUserViewModel = new AspNetUserViewModel(); pmycompany.TerritoryViewModel = new TerritoryViewModel(); pmycompany.RegionViewModel = new RegionViewModel(); //switch (id) //{ // case "Users": // ViewBag.TabName = "Users"; var userList = new AspNetUserViewModel(); userList.Users = new List <AspUser>(); var appUser = new List <UserProfile>(); appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); foreach (var user in appUser.ToList()) { UserSubscription userSubscription = _IUserSubscriptionRepository.GetUserSubscriptionByUserID(user.UserGUID); GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByID(user.UserGUID); string Regionname = string.Empty; string Territoryname = string.Empty; string Groupname = string.Empty; string userType = string.Empty; if (_globalUser != null) { OrganizationUsersMap _orgUserMap = _IOrganizationRepository.GetOrganizationUserMapByUserGUID(user.UserGUID); if (_orgUserMap != null && _orgUserMap.RegionGUID != null) { Regionname = _IRegionRepository.GetRegionNameByRegionGUID(new Guid(_orgUserMap.RegionGUID.ToString())); } else { Regionname = ""; } if (_orgUserMap != null && _orgUserMap.TerritoryGUID != null) { Territoryname = _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(_orgUserMap.TerritoryGUID.ToString())); } else { Territoryname = ""; } // Groupname = _IGroupRepository.GetGroupNameByGroupGUID(new Guid(_globalUser.GroupGUID.ToString())); userType = _IGlobalUserRepository.GetUserTypeByRoleID(_globalUser.Role_Id); } string UserTypeName = _IGlobalUserRepository.GetUserRoleName(user.UserGUID); if (userSubscription != null) { userList.Users.Add(new AspUser { UserTypeName = UserTypeName, RegionName = Regionname, TerritoryName = Territoryname, GroupName = Groupname, OrganizationSubscriptionGUID = userSubscription.OrganizationSubscriptionGUID.ToString(), UserType = userType, IsActive = userSubscription.IsActive, SubscriptionGUID = userSubscription.UserSubscriptionGUID.ToString(), FirstName = user.FirstName, LastName = user.LastName, Id = user.UserGUID.ToString(), EmailID = user.EmailID, MobilePhone = user.MobilePhone, City = user.City, State = user.State, Country = user.Country }); } } OrganizationSubscription orgSubscription = new OrganizationSubscription(); if (Session["UserType"] != null && Session["UserType"].ToString() != "WIM_A") { orgSubscription = _IOrganizationSubscriptionRepository.GetOrganizationSubscriptionByOrgID(new Guid(Session["OrganizationGUID"].ToString())); if (orgSubscription != null) { ViewBag.EnableCreateUserButton = "true"; } else { ViewBag.EnableCreateUserButton = "false"; } //if (orgSubscription != null && orgSubscription.SubscriptionPurchased > orgSubscription.SubscriptionConsumed) //{ // ViewBag.EnableCreateUserButton = "true"; //} //else //{ // ViewBag.EnableCreateUserButton = "false"; //} } else { ViewBag.EnableCreateUserButton = "false"; } pmycompany.AspNetUserViewModel = userList; // break; //case "Region": // ViewBag.TabName = "Regions"; var territoryList = new TerritoryViewModel(); territoryList.Territory = new List <TerritoryModel>(); List <Territory> appTerritory = new List <Territory>(); if (!string.IsNullOrEmpty(regionguid) && regionguid != Guid.Empty.ToString()) { appTerritory = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(regionguid)).ToList(); TempData["TabName"] = "Markets"; ViewBag.AddTerritory = "true"; ViewBag.Id = regionguid; } else { appTerritory = _ITerritoryRepository.GetTerritoryByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); } foreach (var territory in appTerritory.ToList()) { territoryList.Territory.Add(new TerritoryModel { Name = territory.Name, TerritoryGUID = territory.TerritoryGUID.ToString(), RegionGUID = territory.RegionGUID != null ? territory.RegionGUID.ToString() : Guid.Empty.ToString(), Description = territory.Description, OrganizationGUID = territory.OrganizationGUID != null ? territory.OrganizationGUID.ToString() : Guid.Empty.ToString() }); } StringBuilder sb = new StringBuilder(); sb.Append("<div class='actions'>"); sb.Append("<div class='btn-group'>"); if (!string.IsNullOrEmpty(regionguid) && regionguid != Guid.Empty.ToString()) { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _IRegionRepository.GetRegionNameByRegionGUID(new Guid(regionguid)) + " <i class='icon-angle-down'></i></a>"); } else { if (!string.IsNullOrEmpty(selection) && selection == "All") { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>All<i class='icon-angle-down'></i></a>"); } else { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> Select Region <i class='icon-angle-down'></i></a>"); } } sb.Append("<ul id='ulworkgroup' style='height:100px;overflow-y:scroll' class='dropdown-menu pull-right'>"); if (string.IsNullOrEmpty(selection) || selection != "All") { sb.Append("<li><a href=" + Url.Action("Index", "MyCompany", new { id = "Markets", selection = "All" }) + ">All</a></li>"); } List <Region> RegList = _IRegionRepository.GetRegionByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); foreach (Region item in RegList) { sb.Append("<li><a href=" + Url.Action("Index", "MyCompany", new { regionguid = item.RegionGUID.ToString() }) + " data-groupguid=" + item.RegionGUID + ">" + item.Name + "</a></li>"); } sb.Append("</ul>"); sb.Append("</div>"); sb.Append("</div>"); ViewBag.RegionList = sb.ToString(); pmycompany.TerritoryViewModel = territoryList; // break; //case "Territory": // ViewBag.TabName = "Territories"; var regionList = new RegionViewModel(); regionList.Region = new List <RegionModel>(); var appRegion = _IRegionRepository.GetRegionByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); foreach (var region in appRegion.ToList()) { regionList.Region.Add(new RegionModel { Name = region.Name, RegionGUID = region.RegionGUID.ToString(), Description = region.Description, OrganizationGUID = region.OrganizationGUID != null ? region.OrganizationGUID.ToString() : Guid.Empty.ToString() }); } pmycompany.RegionViewModel = regionList; // break; //case "Organization": // ViewBag.TabName = "Details"; OrganizationEditView organization = new OrganizationEditView(); organization.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); Organization Organization = _IOrganizationRepository.GetOrganizationByID(organization.OrganizationGUID); if (organization != null) { organization.OrganizationFullName = Organization.OrganizationFullName; organization.OrganizationName = Organization.OrganizationFullName.Trim(); organization.OrganizationGUID = Organization.OrganizationGUID; organization.Website = Organization.Website; organization.Phone = Organization.Phone; organization.TimeZone = Organization.TimeZone.ToString(); organization.AddressLine1 = Organization.AddressLine1; organization.AddressLine2 = Organization.AddressLine2; organization.ImageURL = Organization.ImageURL; organization.City = Organization.City; organization.Country = Organization.Country; organization.State = Organization.State; organization.ZipCode = Organization.ZipCode; organization.EmailID = Organization.EmailID; organization.IsActive = Organization.IsActive; organization.IsDeleted = Organization.IsDeleted; organization.CreatedDate = Organization.CreateDate; organization.CreateBy = Organization.CreateBy; pmycompany.OrganizationEditView = organization; } // break; //default: // ViewBag.TabName = "Details"; // OrganizationEditView porganization = new OrganizationEditView(); // porganization.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); // Organization pOrganization = _IOrganizationRepository.GetOrganizationByID(porganization.OrganizationGUID); // if (porganization != null) // { // porganization.OrganizationFullName = pOrganization.OrganizationFullName; // porganization.OrganizationName = pOrganization.OrganizationFullName.Trim(); // porganization.OrganizationGUID = pOrganization.OrganizationGUID; // porganization.Website = pOrganization.Website; // porganization.Phone = pOrganization.Phone; // porganization.TimeZone = pOrganization.TimeZone.ToString(); // porganization.AddressLine1 = pOrganization.AddressLine1; // porganization.AddressLine2 = pOrganization.AddressLine2; // porganization.ImageURL = pOrganization.ImageURL; // porganization.City = pOrganization.City; // porganization.Country = pOrganization.Country; // porganization.State = pOrganization.State; // porganization.ZipCode = pOrganization.ZipCode; // porganization.EmailID = pOrganization.EmailID; // porganization.IsActive = pOrganization.IsActive; // porganization.IsDeleted = pOrganization.IsDeleted; // porganization.CreatedDate = pOrganization.CreateDate; // porganization.CreateBy = pOrganization.CreateBy; // pmycompany.OrganizationEditView.Add(porganization); // } // break; // } return(View(pmycompany)); } else { return(RedirectToAction("SessionTimeOut", "User")); } } catch (Exception ex) { Logger.Error(ex.Message); return(RedirectToAction("Login", "User")); } }
private AspNetUserViewModel UserDetails() { #region UserDetails try { var userList = new AspNetUserViewModel(); userList.Users = new List <AspUser>(); var appUser = new List <UserProfile>(); appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); foreach (var user in appUser.ToList()) { UserSubscription userSubscription = _IUserSubscriptionRepository.GetUserSubscriptionByUserID(user.UserGUID); GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByID(user.UserGUID); string Regionname = string.Empty; string Territoryname = string.Empty; string Groupname = string.Empty; string userType = string.Empty; if (_globalUser != null) { OrganizationUsersMap _orgUserMap = _IOrganizationRepository.GetOrganizationUserMapByUserGUID(user.UserGUID); if (_orgUserMap != null && _orgUserMap.RegionGUID != null) { Regionname = _IRegionRepository.GetRegionNameByRegionGUID(new Guid(_orgUserMap.RegionGUID.ToString())); } else { Regionname = ""; } if (_orgUserMap != null && _orgUserMap.TerritoryGUID != null) { Territoryname = _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(_orgUserMap.TerritoryGUID.ToString())); } else { Territoryname = ""; } //Regionname = _IRegionRepository.GetRegionNameByRegionGUID(new Guid(_IOrganizationRepository.GetOrganizationUserMapByUserGUID(user.UserGUID).RegionGUID.ToString())); //Territoryname = _ITerritoryRepository.GetTerritoryNameByTerritoryGUID(new Guid(_IOrganizationRepository.GetOrganizationUserMapByUserGUID(user.UserGUID).TerritoryGUID.ToString())); userType = _IGlobalUserRepository.GetUserTypeByRoleID(_globalUser.Role_Id); } string UserTypeName = _IGlobalUserRepository.GetUserRoleName(user.UserGUID); if (userSubscription != null) { userList.Users.Add(new AspUser { UserTypeName = UserTypeName, RegionName = Regionname, TerritoryName = Territoryname, GroupName = Groupname, OrganizationSubscriptionGUID = userSubscription.OrganizationSubscriptionGUID.ToString(), UserType = userType, IsActive = userSubscription.IsActive, SubscriptionGUID = userSubscription.UserSubscriptionGUID.ToString(), FirstName = user.FirstName, LastName = user.LastName, Id = user.UserGUID.ToString(), EmailID = user.EmailID, MobilePhone = user.MobilePhone, City = user.City, State = user.State, Country = user.Country }); } } OrganizationSubscription orgSubscription = new OrganizationSubscription(); if (Session["UserType"] != null && Session["UserType"].ToString() != "WIM_A") { orgSubscription = _IOrganizationSubscriptionRepository.GetOrganizationSubscriptionByOrgID(new Guid(Session["OrganizationGUID"].ToString())); if (orgSubscription != null) { ViewBag.EnableCreateUserButton = "true"; } else { ViewBag.EnableCreateUserButton = "false"; } //if (orgSubscription != null && orgSubscription.SubscriptionPurchased > orgSubscription.SubscriptionConsumed) //{ // ViewBag.EnableCreateUserButton = "true"; //} //else //{ // ViewBag.EnableCreateUserButton = "false"; //} } else { ViewBag.EnableCreateUserButton = "false"; } return(userList); } catch (Exception ex) { Logger.Error(ex.Message); return(null); } #endregion }