Example #1
0
        public void RefreshCoordinates()
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var organizationsList = repositoriesContainer.RepositoryFor <Organization>().GetAll().ToList();

                IGeoCoder geoCoder = new GoogleGeoCoder();

                foreach (var mapObject in organizationsList)
                {
                    var organization = mapObject;

                    var addresses = geoCoder.GeoCode(organization.Address).ToList();

                    if (addresses.Any())
                    {
                        organization.Latitude  = addresses.First().Coordinates.Latitude;
                        organization.Longitude = addresses.First().Coordinates.Longitude;
                    }
                }

                repositoriesContainer.RepositoryFor <Organization>().Save(organizationsList);
                repositoriesContainer.ApplyChanges();
            }
        }
        public ActionResult _UsersList(int?pageNumber = 1, bool?safeMode = false, string text = null)
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                IPageableList <ChatUser> usersPageableList = new PageableList <ChatUser>();

                if (safeMode.HasValue && safeMode.Value)
                {
                    usersPageableList = repositoriesContainer.RepositoryFor <ChatUser>()
                                        .GetPageableBy(new PageableQuery <ChatUser>(new PageInfo
                    {
                        PageNumber = pageNumber ?? 1,
                        PageSize   = 10
                    })
                                                       .AddFilterClause(e => string.IsNullOrEmpty(text) || e.Login.Contains(text) || e.Name.Contains(text))
                                                       .AddFilterClause(e => e.SafeModeActivated));
                }
                else
                {
                    usersPageableList = repositoriesContainer.RepositoryFor <ChatUser>()
                                        .GetPageableBy(new PageableQuery <ChatUser>(new PageInfo
                    {
                        PageNumber = pageNumber ?? 1,
                        PageSize   = 10
                    })
                                                       .AddFilterClause(e => string.IsNullOrEmpty(text) || e.Login.Contains(text) || e.Name.Contains(text)));
                }

                var chatUsersList =
                    usersPageableList.Items.Select(
                        e => new ChatUserViewModel(e, ConfigurationManager.AppSettings["XmppServerName"])).ToList();
                var chatUsersPageableList = new PageableList <ChatUserViewModel>
                {
                    HasNext     = usersPageableList.HasNext,
                    HasPrevious = usersPageableList.HasPrevious,
                    Items       = chatUsersList,
                    PageInfo    = usersPageableList.PageInfo,
                    TotalCount  = usersPageableList.TotalCount
                };

                var model = new UsersViewModel
                {
                    XmppAdminLogin =
                        ConfigurationManager.AppSettings["XmppAdminLogin"] + "@" +
                        ConfigurationManager.AppSettings["XmppServerName"],
                    XmppAdminPassword  = ConfigurationManager.AppSettings["XmppAdminPassword"],
                    HttpBindAddress    = ConfigurationManager.AppSettings["httpBindAdress"],
                    chatUserViewModels = chatUsersPageableList,
                    MessageTemplates   = GetMessageTemplates()
                };

                ViewData["text"] = text;

                return(View(model));
            }
        }
Example #3
0
 public User GetUser(IQuery <User> query)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <User>().GetBy(query));
     }
 }
        public ActionResult Index(int?pageNumber = 1)
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var errors = repositoriesContainer.RepositoryFor <Error>().GetPageableBy(new PageableQuery <Error>(new PageInfo
                {
                    PageNumber = pageNumber ?? 1,
                    PageSize   = 15
                }).OrderBy(new SortCriteria("Date", SortDirection.Desc)));

                var viewModels = errors.Items.Select(e => new ErrorViewModel
                {
                    Id    = e.Id,
                    Title = e.Message,
                    Time  = e.Date,
                });

                return(View(new PageableList <ErrorViewModel>
                {
                    Items = viewModels.ToList(),
                    HasNext = errors.HasNext,
                    HasPrevious = errors.HasPrevious,
                    TotalCount = errors.TotalCount,
                    PageInfo = errors.PageInfo
                }));
            }
        }
Example #5
0
 public void UpdateUser(User user)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         repositoriesContainer.RepositoryFor <User>().Save(user);
     }
 }
Example #6
0
 public IEnumerable <Role> GetAllRoles()
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Role>().GetAll());
     }
 }
Example #7
0
 public bool IsExistsUser(IQuery <User> query)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <User>().GetBy(query) != null);
     }
 }
 public IPageableList <Person> GetPersons(string text, IPageInfo pageInfo)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Person>().GetPageableBy(new PageableQuery <Person>(pageInfo).AddFilterClause(e => (e.LastName + " " + e.Name + " " + e.MiddleName).Contains(text) || string.IsNullOrEmpty(text))));
     }
 }
        public ActionResult Index(int?pageNumber = 1)
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var templates = repositoriesContainer.RepositoryFor <MessageTemplate>().GetPageableBy(new PageableQuery <MessageTemplate>(new PageInfo
                {
                    PageNumber = pageNumber ?? 1,
                    PageSize   = 15
                }));

                var viewModels = templates.Items.Select(e => new MessageTemplateViewModel
                {
                    Id      = e.Id,
                    Title   = e.Title,
                    Blocked = e.Blocked
                });

                return(View(new PageableList <MessageTemplateViewModel>
                {
                    Items = viewModels.ToList(),
                    HasNext = templates.HasNext,
                    HasPrevious = templates.HasPrevious,
                    TotalCount = templates.TotalCount,
                    PageInfo = templates.PageInfo
                }));
            }
        }
Example #10
0
 public IPageableList <Resource> GetResources(string text, IPageInfo pageInfo)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Resource>().GetPageableBy(new PageableQuery <Resource>(pageInfo).AddFilterClause(e => e.Title.Contains(text) || string.IsNullOrEmpty(text))));
     }
 }
Example #11
0
 public Organization GetOrganization(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Organization>().GetBy(new Query <Organization>(e => e.Id == id).Include(e => e.ActivitiesDirections).Include(e => e.ActivitiesTypes).Include(e => e.OrganizationForm)));
     }
 }
Example #12
0
 public void Save(Project project)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         repositoriesContainer.RepositoryFor <Project>().Save(project);
         repositoriesContainer.ApplyChanges();
     }
 }
 public void Save(Person person)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         repositoriesContainer.RepositoryFor <Person>().Save(person);
         repositoriesContainer.ApplyChanges();
     }
 }
 public Person GetPerson(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Person>().GetBy(new Query <Person>(e => e.Id == id)
                                                                     .Include(e => e.PersonStatuses)));
     }
 }
Example #15
0
 public Project GetProject(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Project>().GetBy(new Query <Project>(e => e.Id == id)
                                                                      .Include(e => e.ActivitiesDirections)
                                                                      .Include(e => e.ProjectState)));
     }
 }
Example #16
0
 public ProjectContactRelation GetProjectPersonRelation(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <ProjectContactRelation>().GetBy(new Query <ProjectContactRelation>(e => e.Id == id)
                                                                                     .Include(e => e.Person)
                                                                                     .Include(e => e.Project)
                                                                                     .Include(e => e.ProjectContactTypes)));
     }
 }
Example #17
0
 public OrganizationsRelation GetOrganizationsRelation(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <OrganizationsRelation>().GetBy(new Query <OrganizationsRelation>(e => e.Id == id)
                                                                                    .Include(e => e.PrimaryOrganization)
                                                                                    .Include(e => e.DependentOrganization)
                                                                                    .Include(e => e.OrganizationsRelationType)));
     }
 }
Example #18
0
 public OrganizationContactRelation GetOrganizationPersonRelation(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <OrganizationContactRelation>().GetBy(new Query <OrganizationContactRelation>(e => e.Id == id)
                                                                                          .Include(e => e.Organization)
                                                                                          .Include(e => e.Person)
                                                                                          .Include(e => e.OrganizationContactRelationTypes)));
     }
 }
Example #19
0
 public Resource GetResource(int id)
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.RepositoryFor <Resource>().GetBy(new Query <Resource>(e => e.Id == id)
                                                                       .Include(e => e.Organization)
                                                                       .Include(e => e.Project)
                                                                       .Include(e => e.ResourceState)
                                                                       .Include(e => e.ResourceType)));
     }
 }
        public ActionResult Edit(int id)
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var template = repositoriesContainer.RepositoryFor <MessageTemplate>().GetBy(new Query <MessageTemplate>(e => e.Id == id));

                return(View(new MessageTemplateViewModel
                {
                    Id = template.Id,
                    Title = template.Title,
                    Text = template.Message,
                    Blocked = template.Blocked
                }));
            }
        }
        public ActionResult Error(int id)
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var error = repositoriesContainer.RepositoryFor <Error>().GetBy(new Query <Error>(e => e.Id == id));

                return(View(new ErrorViewModel
                {
                    AuthorizedUzer = error.Identity,
                    DetailedException = error.Exception,
                    Id = error.Id,
                    Time = error.Date,
                    Title = error.Message
                }));
            }
        }