public ActionResult Index(string id = "") { Logger.Debug("Inside User Controller- Index"); try { if (Session["OrganizationGUID"] != null) { var userList = new AspNetUserViewModel(); userList.Users = new List<AspUser>(); var appUser = new List<UserProfile>(); if (string.IsNullOrEmpty(id)) { appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); } else { appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(id)).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 }); } userList.Users = userList.Users.OrderBy(sort => sort.FirstName).ToList(); DropdownValues(); OrganizationSubscription orgSubscription = new OrganizationSubscription(); if (Session["UserType"] != null && Session["UserType"].ToString() != "WIM_A") { if (string.IsNullOrEmpty(id)) { orgSubscription = _IOrganizationSubscriptionRepository.GetOrganizationSubscriptionByOrgID(new Guid(Session["OrganizationGUID"].ToString())); } else { orgSubscription = _IOrganizationSubscriptionRepository.GetOrganizationSubscriptionByOrgID(new Guid(id)); } if (orgSubscription != null) { ViewBag.EnableCreateUserButton = "true"; } //if (orgSubscription != null && orgSubscription.SubscriptionPurchased > orgSubscription.SubscriptionConsumed) //{ // ViewBag.EnableCreateUserButton = "true"; //} //else //{ // ViewBag.EnableCreateUserButton = "false"; //} } else { ViewBag.EnableCreateUserButton = "false"; } return View(userList.Users.AsEnumerable()); } else { 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 }
public ActionResult Contact(string id = "") { Logger.Debug("Inside People Controller- Create"); try { if (Session["OrganizationGUID"] != null) { var userList = new AspNetUserViewModel(); userList.Users = new List<AspUser>(); var appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); //if (string.IsNullOrEmpty(id)) { userList.Users.Add(new AspUser { FirstName = "All", LastName = "", UserGUID = Guid.Empty.ToString(), OrganizationGUID = "" }); foreach (var user in appUser.ToList()) { userList.Users.Add(new AspUser { FirstName = user.FirstName, LastName = user.LastName, UserGUID = user.UserGUID.ToString() }); } } var placeList = new PlaceViewModel(); placeList.PlaceList = new List<PlaceModel>(); var appPlace = new List<Place>(); if (string.IsNullOrEmpty(id) || Guid.Empty == new Guid(id)) { appPlace = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); if (!string.IsNullOrEmpty(id) && Guid.Empty == new Guid(id)) ViewBag.UserID = Guid.Empty.ToString(); } else { appPlace = _IPlaceRepository.GetPlaceByUserGUID(new Guid(id)).ToList(); ViewBag.UserID = id; } foreach (var place in appPlace.ToList()) { placeList.PlaceList.Add(new PlaceModel { PlaceGUID = place.PlaceGUID.ToString(), PlaceID = place.PlaceID, PlaceName = place.PlaceName, PlacePhone = place.PlacePhone, FirstName = place.FirstName, LastName = place.LastName, UserGUID = place.UserGUID.ToString(), OrganizationGUID = place.OrganizationGUID != null ? place.OrganizationGUID.ToString() : Guid.Empty.ToString(), MobilePhone = place.MobilePhone, HomePhone = place.HomePhone, Emails = place.Emails, TimeZone = place.TimeZone, AddressLine1 = place.AddressLine1, AddressLine2 = place.AddressLine2, City = place.City, State = place.State, Country = place.Country, ZipCode = place.ZipCode }); } var placeviewModel = new PlaceViewModel(); placeviewModel.Place = placeList.PlaceList.AsEnumerable(); placeviewModel.User = userList.Users.AsEnumerable(); var PeopleViewForCreate = new PeopleViewForCreate(); PeopleViewForCreate.PlaceViewModel = placeviewModel; if (TempData["PeopleModel"] != null) PeopleViewForCreate.PeopleModel = (PeopleModel)TempData["PeopleModel"]; //if (string.IsNullOrEmpty(id)) return View(PeopleViewForCreate); //else // return PartialView("../Place/_customer", PeopleViewForCreate); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("Login", "User"); } }
public ActionResult Contact(PeopleViewForCreate peoplecreate) { Logger.Debug("Inside Place Controller- Create Http Post"); try { if (Session["OrganizationGUID"] != null) { if (ModelState.IsValid) { PeopleModel people = new PeopleModel(); people = peoplecreate.PeopleModel; Person People = new Person(); People.PeopleGUID = Guid.NewGuid(); People.UserGUID = new Guid(people.UserGUID.ToString()); if (!string.IsNullOrEmpty(people.OrganizationGUID.ToString()) && people.OrganizationGUID != Guid.Empty.ToString()) { People.OrganizationGUID = new Guid(people.OrganizationGUID.ToString()); } else { People.OrganizationGUID = null; } People.IsPrimaryContact = true; if (!string.IsNullOrEmpty(people.PlaceGUID.ToString()) && people.PlaceGUID != Guid.Empty.ToString()) { People.PlaceGUID = new Guid(people.PlaceGUID.ToString()); } else { People.PlaceGUID = null; } People.FirstName = people.FirstName; People.LastName = people.LastName; People.MobilePhone = people.MobilePhone; People.CompanyName = people.CompanyName; People.BusinessPhone = people.BusinessPhone; People.HomePhone = people.HomePhone; People.Emails = people.Emails; People.AddressLine1 = people.AddressLine1; People.AddressLine2 = people.AddressLine2; People.City = people.City; People.State = people.State; People.Country = people.Country; People.ZipCode = people.ZipCode; People.CategoryID = 0; People.IsDeleted = false; People.CreatedDate = DateTime.UtcNow; People.UpdatedDate = DateTime.UtcNow; int peopleInsertResult = _IPeopleRepository.InsertPeople(People); //int peopleInsertResult = _IPeopleRepository.Save(); if (peopleInsertResult > 0) { ContactValues contactValues = new ContactValues(); contactValues.UserGUID = People.UserGUID; contactValues.OrganizationGUID = People.OrganizationGUID != null ? new Guid(People.OrganizationGUID.ToString()) : Guid.Empty; contactValues.OwnerGUID = People.PlaceGUID != null ? new Guid(People.PlaceGUID.ToString()) : Guid.Empty; contactValues.PrimaryContactGUID = People.PeopleGUID; contactValues.ContactName = People.FirstName; TempData["ContactDetails"] = contactValues; return RedirectToAction("Create"); } else { return View(peoplecreate); } } else { var userList = new AspNetUserViewModel(); userList.Users = new List<AspUser>(); var appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); //if (string.IsNullOrEmpty(id)) { userList.Users.Add(new AspUser { FirstName = "All", LastName = "", UserGUID = Guid.Empty.ToString(), OrganizationGUID = "" }); foreach (var user in appUser.ToList()) { userList.Users.Add(new AspUser { FirstName = user.FirstName, LastName = user.LastName, UserGUID = user.UserGUID.ToString() }); } } var placeList = new PlaceViewModel(); placeList.PlaceList = new List<PlaceModel>(); var appPlace = new List<Place>(); appPlace = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); foreach (var place in appPlace.ToList()) { placeList.PlaceList.Add(new PlaceModel { PlaceGUID = place.PlaceGUID.ToString(), PlaceID = place.PlaceID, PlaceName = place.PlaceName, PlacePhone = place.PlacePhone, FirstName = place.FirstName, LastName = place.LastName, UserGUID = place.UserGUID.ToString(), OrganizationGUID = place.OrganizationGUID != null ? place.OrganizationGUID.ToString() : Guid.Empty.ToString(), MobilePhone = place.MobilePhone, HomePhone = place.HomePhone, Emails = place.Emails, TimeZone = place.TimeZone, AddressLine1 = place.AddressLine1, AddressLine2 = place.AddressLine2, City = place.City, State = place.State, Country = place.Country, ZipCode = place.ZipCode }); } var placeviewModel = new PlaceViewModel(); placeviewModel.Place = placeList.PlaceList.AsEnumerable(); placeviewModel.User = userList.Users.AsEnumerable(); var PeopleViewForCreate = new PeopleViewForCreate(); PeopleViewForCreate.PlaceViewModel = placeviewModel; return View(PeopleViewForCreate); } } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return View(peoplecreate); } }
public ActionResult Edit(string id = "", string peopleguid = "") { Logger.Debug("Inside People Controller- Create"); try { if (Session["OrganizationGUID"] != null) { TempData["TabName"] = "Contacts"; Person EditPeople = _IPeopleRepository.GetPeopleByID(new Guid(peopleguid)); PeopleModel people = new PeopleModel(); if (EditPeople != null) { ViewBag.ContactName = EditPeople.FirstName; people.PeopleGUID = EditPeople.PeopleGUID.ToString(); people.UserGUID = EditPeople.UserGUID.ToString(); people.OrganizationGUID = EditPeople.OrganizationGUID != null ? EditPeople.OrganizationGUID.ToString() : Guid.Empty.ToString(); people.IsPrimaryContact = Convert.ToBoolean(EditPeople.IsPrimaryContact); people.PlaceGUID = EditPeople.PlaceGUID != null ? EditPeople.PlaceGUID.ToString() : Guid.Empty.ToString(); people.FirstName = EditPeople.FirstName; people.LastName = EditPeople.LastName; people.MobilePhone = EditPeople.MobilePhone; people.CompanyName = EditPeople.CompanyName; people.BusinessPhone = EditPeople.BusinessPhone; people.HomePhone = EditPeople.HomePhone; people.Emails = EditPeople.Emails; people.AddressLine1 = EditPeople.AddressLine1; people.AddressLine2 = EditPeople.AddressLine2; people.City = EditPeople.City; people.State = EditPeople.State; people.Country = EditPeople.Country; people.ZipCode = EditPeople.ZipCode; } var userList = new AspNetUserViewModel(); userList.Users = new List<AspUser>(); var appUser = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).OrderBy(sort => sort.FirstName).ToList(); //if (string.IsNullOrEmpty(id)) { userList.Users.Add(new AspUser { FirstName = "All", LastName = "", UserGUID = Guid.Empty.ToString(), OrganizationGUID = "" }); foreach (var user in appUser.ToList()) { userList.Users.Add(new AspUser { FirstName = user.FirstName, LastName = user.LastName, UserGUID = user.UserGUID.ToString() }); } } var placeList = new PlaceViewModel(); placeList.PlaceList = new List<PlaceModel>(); var appPlace = new List<Place>(); if (string.IsNullOrEmpty(id) || Guid.Empty == new Guid(id)) { appPlace = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); if (!string.IsNullOrEmpty(id) && Guid.Empty == new Guid(id)) ViewBag.UserID = Guid.Empty.ToString(); } else { appPlace = _IPlaceRepository.GetPlaceByUserGUID(new Guid(id)).ToList(); ViewBag.UserID = id; } foreach (var place in appPlace.ToList()) { placeList.PlaceList.Add(new PlaceModel { PlaceGUID = place.PlaceGUID.ToString(), PlaceID = place.PlaceID, PlaceName = place.PlaceName, PlacePhone = place.PlacePhone, FirstName = place.FirstName, LastName = place.LastName, UserGUID = place.UserGUID.ToString(), OrganizationGUID = place.OrganizationGUID != null ? place.OrganizationGUID.ToString() : Guid.Empty.ToString(), MobilePhone = place.MobilePhone, HomePhone = place.HomePhone, Emails = place.Emails, TimeZone = place.TimeZone, AddressLine1 = place.AddressLine1, AddressLine2 = place.AddressLine2, City = place.City, State = place.State, Country = place.Country, ZipCode = place.ZipCode }); } var placeviewModel = new PlaceViewModel(); placeviewModel.Place = placeList.PlaceList.AsEnumerable(); placeviewModel.User = userList.Users.AsEnumerable(); var PeopleViewForCreate = new PeopleViewForCreate(); PeopleViewForCreate.PlaceViewModel = placeviewModel; PeopleViewForCreate.PeopleModel = people; return View(PeopleViewForCreate); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("Login", "User"); } }