コード例 #1
0
        public void CanCreateANewEvent()
        {
            var eventTypeRepository = MockRepository.GenerateStub<IEventRepository>();

            var permissionRepository = new PermissionRepository();
            var personRepository = new PersonRepository(permissionRepository, new ChurchRepository());
            var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository);
            var groupRepository = new GroupRepository();
            var messageRepository = new MessageRepository();
            var messageRecepientRepository = new MessageRecepientRepository();
            var messageAttachmentRepository = new MessageAttachmentRepository();
            var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository);
            var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository();
            var emailContentRepository = new EmailContentRepository();
            var emailContentService = new EmailContentService(emailContentRepository);
            var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository);
            IEventService eventTypeService = new EventService(eventTypeRepository, emailService, new BirthdayAndAniversaryRepository());
            var newEvent = new EventDto();
            eventTypeRepository
                .Expect(e => e.SaveItem(newEvent))
                .Return(1);
            var result = eventTypeService.CreateEvent(newEvent);

            Assert.That(result, Is.EqualTo(1));
        }
コード例 #2
0
        public ActionResult Edit()
        {
            GroupsEditVM model = new GroupsEditVM();
            TryUpdateModel(model);
            GroupRepository groupRep = new GroupRepository();

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            Group group;
            if (model.ID == 0)
            {
                group = new Group();
            }
            else
            {
                group = groupRep.GetByID(model.ID);
                if (group == null)
                {
                    return RedirectToAction("List");
                }
            }

            group.Name = model.Name;

            groupRep.Save(group);

            return RedirectToAction("List");
        }
コード例 #3
0
        public ActionResult CreateGroup(Group group)
        {
            var rep = new GroupRepository();
            rep.Create(group);

            return RedirectToAction("Group");
        }
コード例 #4
0
        public void CanGetCreatedEvent()
        {
            var eventRepository = MockRepository.GenerateStub<IEventRepository>();
            var expectedEventDto = new EventDto
            {
                EventId = 1
            };
            eventRepository
                .Expect(et => et.GetItem(1))
                .Return(expectedEventDto);

            var permissionRepository = new PermissionRepository();
            var personRepository = new PersonRepository(permissionRepository, new ChurchRepository());
            var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository);
            var groupRepository = new GroupRepository();
            var messageRepository = new MessageRepository();
            var messageRecepientRepository = new MessageRecepientRepository();
            var messageAttachmentRepository = new MessageAttachmentRepository();
            var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository);
            var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository();
            var emailContentRepository = new EmailContentRepository();
            var emailContentService = new EmailContentService(emailContentRepository);
            var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository);

            IEventService eventService = new EventService(eventRepository, emailService, new BirthdayAndAniversaryRepository());
            var eventDto = eventService.GetEvent(1);
            Assert.That(eventDto, Is.EqualTo(expectedEventDto));
        }
コード例 #5
0
 public GroupMemberService(
         UserRepository userRepository,
         GroupRepository groupRepository)
 {
     this.GroupRepository = groupRepository;
     this.UserRepository = userRepository;
 }
コード例 #6
0
ファイル: GroupController.cs プロジェクト: rwojcik/imsServer
        public GroupController()
        {

            var userName = User?.Identity?.Name ?? "Anonymous";

            _repository = new GroupRepository(userName);
        }
コード例 #7
0
        public ApiScheduleService()
        {
            SessionFactory.Load(ConfigurationManager.ConnectionStrings["Audience"].ConnectionString);

            _facultyRepository = new FacultyRepository();
            _groupRepository = new GroupRepository();
            _subjRepository = new SubjectRepository();
        }
コード例 #8
0
        public ActionResult Delete(int id)
        {
            GroupRepository groupRep = new GroupRepository();

            groupRep.Delete(id);

            return RedirectToAction("List");
        }
コード例 #9
0
 public ActionResult Details(int id)
 {
     GroupRepository groupRepo = new GroupRepository();
     Group group = groupRepo.GetByID(id);
     model.Contacts = group.Contacts.ToList();
     model.GroupId = id;
     return View(model);
 }
コード例 #10
0
 public AuthorizationService(
         UserRepository userRepository,
         GroupRepository groupRepository,
         RoleRepository roleRepository)
 {
     this.GroupRepository = groupRepository;
     this.RoleRepository = roleRepository;
     this.UserRepository = userRepository;
 }
コード例 #11
0
 public StudentInsertWindow()
 {
     InitializeComponent();
     //Student = item;
     Student = new StudentItem();
     Groups = new GroupRepository().GetAll();
     //SelectedGroup = new GroupItem(item.GroupId, item.GroupName);
     DataContext = this;
 }
コード例 #12
0
 public ActionResult Delete(int id)
 {
     GroupRepository groupRepo = new GroupRepository();
     Group group = groupRepo.GetByID(id);
     group.Contacts.Clear();
     groupRepo.Save(group);
     groupRepo.Delete(group);
     return RedirectToAction("ListGroups",new {@parentId = AuthenticationService.LoggedUser.Id });
 }
コード例 #13
0
 public StudentEditWindow(StudentItem item)
 {
     InitializeComponent();
     Student = item;
     Groups = new GroupRepository().GetAll();
     SelectedGroup = Groups[0];
     //SelectedGroup = new DeaneryLibrary.GroupItem();
     //SelectedGroup.Id = item.GroupId; SelectedGroup.Name = item.GroupName;
     DataContext = this;
 }
コード例 #14
0
        public ActionResult EditGroup(int id)
        {
            if (Session["User"] == null)
            {
                return RedirectToAction("Login", "Default");
            }
            else
            {
                ContactRepository ContactRepository = new ContactRepository();
                GroupRepository GroupRepository = new GroupRepository();
                User user = (User)Session["User"];
                List<Contact> contactList = ContactRepository.GetAll(filter: u => u.UserId == user.Id);
                List<SelectListItem> List = new List<SelectListItem>();

                if (id > 0)
                {
                    Group group = new Group();
                    group = GroupRepository.GetByID(id);
                    model.groupName = group.GroupName;

                    foreach (var item in contactList)
                    {
                        SelectListItem one = null;
                        if (group.Contacts.Any(c => c.Id == item.Id))
                        {
                            one = new SelectListItem { Text = item.FullName, Value = item.Id.ToString(), Selected = true };
                        }
                        else
                        {
                            one = new SelectListItem() { Text = item.FullName, Value = item.Id.ToString(), Selected = false };
                        }
                        List.Add(one);
                    }
                    model.ContactList = List;
                    model.GroupId = id;
                }
                if (id == 0)
                {
                    foreach (var item in contactList)
                    {
                        SelectListItem one = new SelectListItem() { Text = item.FullName, Value = item.Id.ToString() };
                        List.Add(one);
                    }
                    model.ContactList = List;
                }
            }
            return View(model);
        }
コード例 #15
0
        public void GetGroups()
        {
            Items.Clear();

            //MOE.Common.Data.InrixTableAdapters.GroupsTableAdapter groupsTA = new Data.InrixTableAdapters.GroupsTableAdapter();
            //MOE.Common.Data.Inrix.GroupsDataTable groupsDT = new Data.Inrix.GroupsDataTable();

            //groupsTA.Fill(groupsDT);

            var gr       = new GroupRepository();
            var groupsDT = gr.GetAll();

            foreach (var row in groupsDT)
            {
                var group = new Group(row.Group_ID, row.Group_Name, row.Group_Description);

                Items.Add(group);
            }
        }
コード例 #16
0
        public ActionResult Details(int?id)
        {
            if (id != null)
            {
                ContactRepository contactRepo = new ContactRepository();

                Contact contact = contactRepo.GetById(id.Value);

                if (contact != null && contact.UserID == AuthenticationService.LoggedUser.ID)
                {
                    ContactCreateEditVM model = new ContactCreateEditVM()
                    {
                        ID        = contact.ID,
                        FirstName = contact.FirstName,
                        LastName  = contact.LastName,
                        Email     = contact.Email
                    };

                    GroupRepository groupRepo = new GroupRepository();

                    List <Group> contactGroups = contactRepo.GetAll(c => c.ID == id).First().Groups;

                    if (contactGroups.Count > 0)
                    {
                        List <CheckBoxListItem> checkBoxListItems = new List <CheckBoxListItem>();

                        foreach (Group group in contactGroups)
                        {
                            checkBoxListItems.Add(new CheckBoxListItem()
                            {
                                Text = group.Name
                            });
                        }

                        model.Groups = checkBoxListItems;
                    }

                    return(View(model));
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #17
0
        public void RemoveMember_AddMember()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);
                    var user    = new User {
                        username = "******"
                    };
                    GroupMember groupMember = new GroupMember {
                        user = user, role = "Developer", groupID = 1
                    };
                    var added        = service.AddMember(groupMember);
                    var existingItem = context.GroupMembers.Any(x => x.Username.Equals("Andrew"));
                    Assert.AreEqual(true, existingItem);
                    bool removed     = service.RemoveMember(groupMember);
                    bool removedItem = context.GroupMembers.Any(x => x.Username.Equals("Andrew"));
                    Assert.AreEqual(false, removedItem);
                    Assert.AreEqual(true, removed);
                }
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #18
0
ファイル: Home.aspx.cs プロジェクト: thinkgandhi/socioboard
        public void AuthenticateLinkedin(object sender, EventArgs e)
        {
            try
            {
                GroupRepository        objGroupRepository = new GroupRepository();
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);

                try
                {
                    int profilecount = (int)Session["ProfileCount"];
                    int totalaccount = (int)Session["TotalAccount"];
                    if (lstDetails.GroupName == "Socioboard")
                    {
                        if (profilecount < totalaccount)
                        {
                            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                            string        authLink       = Linkedin_oauth.AuthorizationLinkGet();
                            Session["reuqestToken"]       = Linkedin_oauth.Token;
                            Session["reuqestTokenSecret"] = Linkedin_oauth.TokenSecret;

                            this.LinkedInLink.HRef = "";
                            this.LinkedInLink.HRef = authLink;
                            Response.Redirect(authLink);
                        }
                        else
                        {
                            //Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>");
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
コード例 #19
0
        public async void CreateGroup_Pass_When_ValidInput()
        {
            using (var applicationDbContext = TestTools.CreateApplicationDbContext()) {
                // Arrange
                string issuerId = "277AAEEC-AC90-4B0E-B1D3-C318AEF1A95C";
                applicationDbContext.Add(new ApplicationUser {
                    Id = issuerId, UserName = "******"
                });

                // Act
                var sut   = new GroupRepository(applicationDbContext);
                var group = await sut.CreateGroup(issuerId, new Domain.Dto.GroupInfo {
                    Name             = "Name for Group",
                    MissionStatement = "Descriptio for Group"
                });

                // Assert
                Assert.NotNull(group);
            }
        }
コード例 #20
0
        public ActionResult Edit(CRUDGroupViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            GroupRepository repository = new GroupRepository();

            Group group = new Group();

            group.Id      = model.Id;
            group.Student = model.Student;
            group.Teacher = model.Teacher;
            group.Name    = model.Name;

            repository.Save(group);

            return(RedirectToAction("Index"));
        }
コード例 #21
0
        public void Delete_NotThrowsException_StateIsValid()
        {
            var now   = DateUtil.Now;
            var group = new GroupTableEntity
            {
                GroupId     = Guid.NewGuid(),
                GroupCode   = new string('Y', 20),
                GroupTree   = new string('1', 8),
                Name        = new string('X', 256),
                Description = new string('X', 1024),
                SortNo      = int.MaxValue,
                Status      = GroupStatus.SUSPENDED.ToString(),
                CreateTime  = DateTimeOffset.MaxValue,
                UpdateTime  = DateTimeOffset.MaxValue,
            };
            var groupRepository = new GroupRepository(TestEnvironment.DBSettings);

            groupRepository.Create(group);
            Assert.IsTrue(groupRepository.Delete(group));
        }
コード例 #22
0
        // GET api/<controller>
        public GroupListModel Get(int employeeId, int page, int rows)
        {
            var employeeType = (EmployeeType)employeeId;
            int totalRecords;
            var model = new GroupListModel
            {
                Rows     = GroupRepository.Search(employeeType, string.Empty, page, rows, out totalRecords),
                Page     = page,
                Total    = (totalRecords / rows) + 1,
                Records  = rows,
                UserData = totalRecords
            };

            if (model.Rows != null)
            {
                var branchId = UserContext.GetDefaultBranch();
                model.Rows = model.Rows.Where(c => c.BranchId == branchId).ToList();
            }
            return(model);
        }
コード例 #23
0
ファイル: UserController.cs プロジェクト: HungNV88/CRM
        public IEnumerable <UserInfo> GetByBranchId(int branchId)
        {
            var groups = StoreData.ListGroup.IsNullOrEmpty() ? GroupRepository.GetAll() : StoreData.ListGroup;

            groups = branchId == 0 ? groups : groups.Where(c => c.BranchId == branchId).ToList();

            var user  = UserContext.GetCurrentUser();
            var users = StoreData.ListUser.IsNullOrEmpty() ? UserRepository.GetAll() : StoreData.ListUser;

            switch (user.GroupConsultantType)
            {
            case (int)GroupConsultantType.ManagerConsultant:
            case (int)GroupConsultantType.LeaderConsultant:
                return(groups == null ? users : users.Where(c => groups.Any(p => p.GroupId == c.GroupId)).ToList());

            case (int)GroupConsultantType.Consultant:
                return(groups == null ? users : users.Where(c => c.UserID == user.UserID).ToList());
            }
            return(null);
        }
コード例 #24
0
        public void RemoveTest()
        {
            Grupo item = new Grupo()
            {
                Descricao = "Grupo00"
            };
            IGroupRepository target = new GroupRepository();

            target.Add(item);
            target.Remove(item);

            // use session to try to load the product
            using (ISession session = NHibernateHelper.OpenSession())
            {
                var fromDb = session.Get <Grupo>(item.Id);

                Assert.IsNull(fromDb);
                Assert.AreNotSame(item, fromDb);
            }
        }
コード例 #25
0
ファイル: Home.aspx.cs プロジェクト: thinkgandhi/socioboard
        public void AuthenticateFacebook(object sender, EventArgs e)
        {
            try
            {
                GroupRepository        objGroupRepository = new GroupRepository();
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);


                try
                {
                    int profilecount = (int)Session["ProfileCount"];
                    int totalaccount = (int)Session["TotalAccount"];

                    if (lstDetails.GroupName == "Socioboard")
                    {
                        if (profilecount < totalaccount)
                        {
                            Session["fbSocial"] = "a";
                            fb_account.HRef     = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,user_groups,offline_access,publish_actions,manage_pages&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                            //fb_account.HRef = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                            // fb_cont.HRef = fb_account.HRef;
                            Response.Redirect(fb_account.HRef);
                        }
                        else
                        {
                            // Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>");
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
コード例 #26
0
        private static Student FindTheRightStudent()
        {
            StudentRepository studentRepository = new StudentRepository();
            GroupRepository   groupRepository   = new GroupRepository();

            System.Console.WriteLine("Введите фамилию студента:");
            string surname = System.Console.ReadLine();

            var  students        = studentRepository.GetStudentsList("LastName", surname);
            int  studentPosition = 0;
            bool check           = false;

            if (students.Count > 0)
            {
                for (int i = 0; i < students.Count; i++)
                {
                    System.Console.WriteLine($"{i + 1}) " +
                                             $"{students[i].FirstName}   " +
                                             $"{students[i].LastName}   " +
                                             $"{students[i].MiddleName}   " +
                                             $"{groupRepository.GetGroupName(students[i].GroupId)}");
                }

                while (!check)
                {
                    System.Console.Write("Выбор: ");
                    check = int.TryParse(System.Console.ReadLine(), out studentPosition);
                    if (studentPosition < 1 || studentPosition > students.Count)
                    {
                        check = false;
                    }
                }
                return(students[studentPosition - 1]);
            }
            else
            {
                System.Console.WriteLine("Не удалось найти ни одного студента по указанной фамилии\n" +
                                         "Нажмите Enter чтобы продолжить, Escape чтобы выйти...");
                return(null);
            }
        }
コード例 #27
0
ファイル: AbonentController.cs プロジェクト: GennadyMV/pogoda
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                string param_name          = collection.Get("Name");
                string param_email         = collection.Get("Email");
                IRepository <Abonent> repo = new AbonentRepository();
                Abonent abonent            = new Abonent();
                abonent       = repo.GetById(id);
                abonent.Name  = param_name;
                abonent.Email = param_email;
                abonent.ClearGroups();
                string   param_groups;
                string[] arrayGroups;

                if (collection.Get("Groups") != null)
                {
                    param_groups = collection.Get("Groups");;
                    arrayGroups  = param_groups.Split(',');

                    foreach (string str in arrayGroups)
                    {
                        int   GroupID = Convert.ToInt32(str);
                        Group group   = new Group();
                        IRepository <Group> repo_group = new GroupRepository();
                        group = repo_group.GetById(GroupID);

                        abonent.Groups.Add(group);
                    }
                }


                repo.Update(abonent);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #28
0
        public void DeleteGroup()
        {
            GroupRepository groupRepository = new GroupRepository(new InMemoryDbContextFactory().CreateDbContext());
            GroupModel      groupModel      = new GroupModel
            {
                Id          = Guid.NewGuid(),
                Name        = "První cenová skupina",
                Description = "Popisek testovací skupiny První cenová skupina"
            };

            groupRepository.Insert(groupModel);
            var groupRepositoryResponse = groupRepository.GetById(groupModel.Id);

            Assert.NotNull(groupRepositoryResponse);
            GroupRepository groupRepository2 = new GroupRepository(new InMemoryDbContextFactory().CreateDbContext());

            groupRepository2.Delete(groupModel);
            var groupRepositoryResponse2 = groupRepository2.GetById(groupModel.Id);

            Assert.Null(groupRepositoryResponse2);
        }
コード例 #29
0
        public void Deveria_Buscar_Permissoes_Por_Grupo()
        {
            var administrador = GroupRepository.GetById(1);

            var permissao = ObjectBuilder.CreatePermission();

            if (administrador.Claims.FirstOrDefault() == null)
                administrador.Claims.Add(ObjectBuilder.CreateClaim());

            administrador.Claims.First().Permissions.Add(permissao);

            Uow.Commit();

            var adminPermissions = PermissionRepository.GetByGroup(administrador.Id);

            Assert.AreEqual(3, adminPermissions.Count);

            var allPermissions = PermissionRepository.GetAll();

            Assert.AreEqual(11, allPermissions.Count);
        }
コード例 #30
0
 public LookUpService()
 {
     _custClassRepo            = new CustClassRepository(context);
     _paymentTermsRepo         = new PaymentTermsRepository(context);
     _statementCycleRepository = new StatementCycleRepository(context);
     _shipMethodRepository     = new ShipMethodRepository(context);
     _businessFormRepository   = new BusinessFormRepository(context);
     _salesSourceRepository    = new SalesSourceRepository(context);
     _branchRepository         = new BranchRepository(context);
     _salesTerritoryRepository = new SalesTerritoryRepository(context);
     _territoryRepository      = new TerritoryRepository(context);
     _countryRepository        = new CountryRepository(context);
     _customerRepository       = new CustomerRepository(context);
     _userRepository           = new UserRepository(context);
     _groupRepository          = new GroupRepository(context);
     _creditCardTypeRepository = new CreditCardTypeRepository(context);
     _stateRepository          = new StateRepository(context);
     _taxSubjClassRepository   = new TaxSubjClassRepository(context);
     _taxScheduleRepository    = new TaxScheduleRepository(context);
     _batchRepository          = new BatchRepository();
 }
コード例 #31
0
        public async Task Delete_ShouldRemove()
        {
            //Arrange
            IGroupRepository sut = new GroupRepository(_context);

            //Act
            await sut.AddAsync(new Group
                               { Name = "someNameToDelete", Country = "someCountryToDelete", CreationYear = 2000 });

            await sut.SaveAsync();

            var expected = (await sut.GetAllAsync()).LastOrDefault();
            await sut.DeleteAsync(expected);

            await sut.SaveAsync();

            var actual = (await sut.GetAllAsync()).LastOrDefault();

            //Assert
            Assert.NotEqual(expected, actual);
        }
コード例 #32
0
        public void Deveria_Excluir_Autorizacao_do_Grupo()
        {
            var grupo = GroupRepository.GetByIdIncluding(2, g => g.Claims);

            var authoExclude = grupo.Claims.Last();

            var authorizationsDTO = new List <ClaimDTO>()
            {
                new ClaimDTO(grupo.Claims.Last())
            };

            AuthorizationService.RemoveAuthorizationFromGroup(grupo.Id, authorizationsDTO.ToArray());
            Uow.Commit();

            var authorizationGroups = ClaimRepository.GetByGroup(grupo.Id);

            grupo = GroupRepository.GetByIdIncluding(2, g => g.Claims);

            Assert.AreEqual(1, grupo.Claims.Count);
            Assert.IsFalse(authorizationGroups.Contains(authoExclude));
        }
コード例 #33
0
        private void btnOpenFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                //Путь к папке с файлами груп и пользователей
                directoryPath = System.IO.Path.GetDirectoryName(openFileDialog.FileName) + @"\";
                //Заргужаем групы по пути полученым из OpenDialog
                groups = GroupRepository.GetInstance(openFileDialog.FileName).GetGroups();
                //Отделяем дату файла груп для открытия файла с пользователями с такой же датой
                string[] stringDate = openFileDialog.FileName.Split(new Char[] { '_' });
                //Создаем путь для файла с датой аналогичной с групами  (Делать ли тут проверку на существующий файл?)
                string userPath = directoryPath + "users_" + stringDate[1];
                //Загружаем пользователей из файла с датой аналогичной групам
                users = UserRepository.GetInstance(userPath).GetUsers();
                // Проверка выполлнения
                txtEditor.Text = "Groups: " + groups.Count().ToString() + " Users: " + users.Count().ToString();
                //txtEditor.Text = System.IO.Path.GetDirectoryName(openFileDialog.FileName);
            }
        }
コード例 #34
0
        public bool IsValid(int id, Group group)
        {
            //If changing owner (which is an organization), validate the change
            CurrentUserOrgIds = CurrentUser.OrganizationIds.OrEmpty();
            var original = GroupRepository.Get()
                           .Where(g => g.Id == id)
                           .Include(g => g.Owner)
                           .FirstOrDefaultAsync().Result;

            ValidateOrganizationHeader(original.OwnerId, "group");
            if (group.OwnerId != VALUE_NOT_SET)
            {
                if ((!CurrentUserOrgIds.Contains(group.OwnerId)) && (!IsCurrentUserSuperAdmin()))
                {
                    var message = "You do not belong to an organization that the group is owned by and therefor cannot reassign ownership";
                    AddError(message);
                }
            }

            return(base.IsValid());
        }
コード例 #35
0
        public IEnumerable <Uni.Models.GroupViewModel> GetGroups()
        {
            App             app             = DataHelper.GetApp();
            GroupRepository groupRepository = new GroupRepository(app);

            IEnumerable <Group> groups = groupRepository.GetAll();

            List <GroupViewModel> list = new List <GroupViewModel>();

            foreach (Group group in groups)
            {
                GroupViewModel model = new GroupViewModel();
                model.GroupId     = group.GroupId;
                model.Name        = group.Name;
                model.ProfName    = string.Format("{0} {1}", group.Prof.FirstName, group.Prof.LastName);
                model.SubjectName = group.Subject.Name;
                list.Add(model);
            }

            return(list);
        }
コード例 #36
0
        public ActionResult CreateEdit(GroupsCreateEditVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Group group;

            GroupRepository groupRepo = new GroupRepository();

            if (model.ID > 0) // Edit
            {
                group = groupRepo.GetById(model.ID);

                if (group == null || group.UserID != model.UserID)
                {
                    return(HttpNotFound());
                }
            }

            else // Create
            {
                group = new Group()
                {
                    UserID = AuthenticationService.LoggedUser.ID
                };
            }

            if (group.UserID == AuthenticationService.LoggedUser.ID)
            {
                group.Name = model.Name;

                groupRepo.Save(group);

                return(RedirectToAction("Index"));
            }

            return(HttpNotFound());
        }
コード例 #37
0
        static void Main(string[] args)
        {
            #region Student Table
            var Student    = new StudentRepository();
            var AllStudent = Student.GetStudentForName();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("|               All students               |");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("____________________________________________");
            Console.WriteLine("|First name |   Last Name  |Card № | Group |");

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var student in AllStudent)
            {
                Console.WriteLine("| {0,10}|{1,13} |{2,6} |{3,7}|",
                                  student.FirstName,
                                  student.LastName,
                                  student.CardNumber,
                                  student.Group.Name);
            }
            Console.WriteLine("____________________________________________");
            Console.ResetColor();
            #endregion

            #region Group Table
            var Groups   = new GroupRepository();
            var AllGroup = Groups.AllGroups();
            Console.WriteLine("_____________________________________________");
            Console.WriteLine("|Group Name|          Faculties       |Group|");
            foreach (var group in AllGroup)
            {
                Console.WriteLine("| {0,9}|{1,26}|{2,5}|",
                                  group.Name,
                                  group.Faculty.Name,
                                  group.Students.Count());
            }
            #endregion

            Console.ReadLine();
        }
コード例 #38
0
        public void ChangeRole()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var  service = new GroupRepository(context);
                    User user    = new User();
                    user.username = "******";
                    GroupMember groupMember = new GroupMember();
                    groupMember.user    = user;
                    groupMember.role    = "Product Owner";
                    groupMember.groupID = 1;
                    service.AddMember(groupMember);
                    Assert.AreEqual("Product Owner", context.GroupMembers.Find("dave").GroupRole);
                    groupMember.role = "Scrum Master";
                    service.ChangeRole(groupMember);
                    Assert.AreEqual("Scrum Master", context.GroupMembers.Find("dave").GroupRole);
                }
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #39
0
 public ProjectImportService(
     IJsonApiContext jsonApiContext,
     UserRepository userRepository,
     GroupRepository groupRepository,
     ICurrentUserContext currentUserContext,
     IEntityRepository <Organization> organizationRepository,
     IEntityRepository <UserRole> userRolesRepository,
     IEntityRepository <ProductDefinition> productDefinitionRepository,
     IEntityRepository <Store> storeRepository,
     IEntityRepository <ProjectImport> projectImportRepository,
     ILoggerFactory loggerFactory) : base(jsonApiContext, projectImportRepository, loggerFactory)
 {
     JsonApiContext              = jsonApiContext;
     UserRepository              = userRepository;
     GroupRepository             = groupRepository;
     CurrentUserContext          = currentUserContext;
     OrganizationRepository      = organizationRepository;
     UserRolesRepository         = userRolesRepository;
     ProductDefinitionRepository = productDefinitionRepository;
     StoreRepository             = storeRepository;
     ProjectImportRepository     = projectImportRepository;
 }
コード例 #40
0
        public static List <GroupEntity> GetGroupAll()
        {
            List <GroupEntity> all    = new List <GroupEntity>();
            GroupRepository    mr     = new GroupRepository();
            List <GroupInfo>   miList = Cache.Get <List <GroupInfo> >("GroupALL");

            if (miList.IsEmpty())
            {
                miList = mr.GetAllGroup();
                Cache.Add("GroupALL", miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (GroupInfo mInfo in miList)
                {
                    GroupEntity GroupEntity = TranslateGroupEntity(mInfo);
                    all.Add(GroupEntity);
                }
            }

            return(all);
        }
コード例 #41
0
        public ActionResult Delete(int?id)
        {
            if (id != null)
            {
                GroupRepository groupRepo = new GroupRepository();

                Group group = groupRepo.GetById(id.Value);

                if (group != null && group.UserID == AuthenticationService.LoggedUser.ID)
                {
                    GroupsCreateEditVM g = new GroupsCreateEditVM()
                    {
                        ID   = group.ID,
                        Name = group.Name
                    };

                    return(View(g));
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #42
0
 public UnitOfWork(DataContext context)
 {
     _context              = context;
     Account               = new AccountRepository(_context);
     AccountHistory        = new AccountHistoryRepository(_context);
     AccountType           = new AccountTypeRepository(_context);
     Business              = new BusinessRepository(_context);
     Client                = new ClientRepository(_context);
     Group                 = new GroupRepository(_context);
     Relationship          = new RelationshipRepository(_context);
     Role                  = new RoleRepository(_context);
     Transaction           = new TransactionRepository(_context);
     TransactionCode       = new TransactionCodeRepository(_context);
     TransactionType       = new TransactionTypeRepository(_context);
     TransactionTypeDetail = new TransactionTypeDetailRepository(_context);
     User                  = new UserRepository(_context);
     UserHistory           = new UserHistoryRepository(_context);
     UserActivity          = new UserActivityRepository(_context);
     Menu                  = new MenuRepository(_context);
     Control               = new ControlRepository(_context);
     Image                 = new ImageRepository(_context);
 }
コード例 #43
0
        public ActionResult Create(CRUDGroupViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Group groups = new Group();

            groups.Name = model.Name;
            //  model.Students = PopuateStudentsList();
            //  model.Teachers = PopuateTeachersList();
            groups.Student = model.Student;
            groups.Teacher = model.Teacher;


            var repository = new GroupRepository();

            repository.Insert(groups);

            return(RedirectToAction("Index"));
        }
コード例 #44
0
        public void LoadGroup()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);

                    GroupMember groupMember = new GroupMember();
                    groupMember.user.username = "******";
                    groupMember.groupID       = 1;
                    groupMember.role          = "Scrum Master";
                    var added = service.AddMember(groupMember);
                    var group = service.LoadGroup(1);
                    Assert.AreEqual(true, added);
                    Assert.AreEqual(1, context.GroupMembers.Count());
                    // Assert.AreEqual(group.GetGroupMembers()[0].user.username, context.GroupMembers.Find("jaime").Username);
                }
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #45
0
ファイル: MainRepository.cs プロジェクト: fgomeza/planillas
 public MainRepository(AppContext context)
 {
     _context = context;
     Calls = new CallRepository(_context);
     Users = new UserRepository(_context);
     Locations = new LocationRepository(_context);
     Groups = new GroupRepository(_context);
     Operations = new OperationRepository(_context);
     Roles = new RoleRepository(_context);
     Debits = new DebitRepository(_context);
     PenaltyTypes = new PenaltyTypeRepository(_context);
     Employees = new EmployeeRepository(_context);
     Extras = new ExtraRepository(_context);
     PayRolls = new PayRollRepository(_context);
     Salaries = new SalaryRepository(_context);
     DebitTypes = new DebitTypeRepository(_context);
     Penalties = new PenaltyRepository(_context);
     DebitPayments = new DebitPaymentRepository(_context);
     Administrators = new AdministratorRepository(_context);
     Savings = new SavingRepository(_context);
     Vacations = new VacationRepository(_context);
     RoleOperations = new RoleOperationRepository(_context);
 }
コード例 #46
0
        public ActionResult Edit(int? id)
        {
            Group group;
            GroupRepository groupRep = new GroupRepository();

            if (!id.HasValue)
            {
                group = new Group();
            }
            else
            {
                group = groupRep.GetByID(id.Value);
                if (group == null)
                {
                    return RedirectToAction("List");
                }
            }

            GroupsEditVM model = new GroupsEditVM();
            model.ID = group.ID;
            model.Name = group.Name;

            return View(model);
        }
コード例 #47
0
ファイル: Html.cs プロジェクト: kioltk/ColonitShopMVC
        public static HtmlString NavigationMenu()
        {
            string navigationMenu = "";

            var rep = new GroupRepository();

            foreach (var group in rep.Table)
            {
                navigationMenu += "<li>";
                navigationMenu += "<a href=\"#\">" + group.title + "</a>";
                navigationMenu +=
                    "<div class=\"submenu\">" +
                        "<ul>"
                ;
                foreach (var category in group.Categories)
                {
                    navigationMenu += "<li class=\"category\">"+category.title+"</li>";
                    foreach (var subcategory in category.Subcategories)
                    {

                        navigationMenu +=
                            "<li class=\"subcategory\">" +
                            "<a href=\"/shop/subcategory/"+ subcategory.ID+"\">" + subcategory.title + "</a>" +
                            "</li>";
                    }
                }

                navigationMenu +=
                    "</ul>"+
                        "</div>";

                navigationMenu += "</li>";
            }

            return new HtmlString(navigationMenu);
        }
コード例 #48
0
 public ActionResult ListGroups(int parentId)
 {
     if (Session["User"] == null)
     {
         return RedirectToAction("Login", "Default");
     }
     else
     {
         ContactRepository ContactRepository = new ContactRepository();
         GroupRepository GroupRepository = new GroupRepository();
         model.UserId = AuthenticationService.LoggedUser.Id;
         model.GroupList = GroupRepository.GetAll(filter: u => u.UserID == parentId);
     }
     return View(model);
 }
コード例 #49
0
        public ActionResult Group()
        {
            var rep = new GroupRepository();

            return View(rep.Table);
        }
コード例 #50
0
        public ActionResult DeleteGroup(int id)
        {
            var rep = new GroupRepository();
            rep.Delete(id);

            return RedirectToAction("Group");
        }
コード例 #51
0
        public ActionResult EditGroup(GroupControllerGroupVM model, FormCollection formCollection, int id)
        {
            UnitOfWork Uow = new UnitOfWork();
            ContactRepository contactRepo = new ContactRepository(Uow);
            GroupRepository groupRepo = new GroupRepository(Uow);
            User user = (User)Session["User"];
            List<Contact> contactList = contactRepo.GetAll(filter: u => u.UserId == user.Id);
            List<SelectListItem> List = new List<SelectListItem>();
            Group group = new Group();
            TryUpdateModel(model);
            if (!this.ModelState.IsValid)
            {
                foreach (var item in contactList)
                {
                    SelectListItem one = new SelectListItem() { Text = item.FullName, Value = item.Id.ToString() };
                    List.Add(one);
                }
                model.ContactList = List;
                return View(model);
            }
            else
            {
                group.UserID = user.Id;
                if (id > 0)
                {
                    group = groupRepo.GetByID(id);
                    group.GroupName = model.groupName;
                    var value = formCollection["ContactId"];
                    if (value != null)
                    {
                        string[] arrValue = formCollection["ContactId"].ToString().Split(',');

                        List<Contact> contacts = new List<Contact>();
                        contacts = group.Contacts.ToList();

                        foreach (var item in contacts)
                        {
                            if (!arrValue.Contains(item.Id.ToString()))
                            {
                                group.Contacts.Remove(contactRepo.GetByID(Convert.ToInt32(item.Id)));
                            }
                        }
                        foreach (var item in arrValue)
                        {
                            List<Contact> cont = contactRepo.GetAll(filter: c => c.UserId == user.Id);
                            if (cont.Any(c => c.Id == Convert.ToInt32(item)))
                            {
                                group.Contacts.Add(contactRepo.GetByID(Convert.ToInt32(item)));
                            }
                        }

                    }
                }
                else
                {
                    group.GroupName = model.groupName;
                    group.Contacts = new List<Contact>();
                    var value = formCollection["ContactId"];
                    if (value != null)
                    {
                        string[] arrValue = formCollection["ContactId"].ToString().Split(',');
                        foreach (var item in arrValue)
                        {
                            group.Contacts.Add(contactRepo.GetByID(Convert.ToInt32(item)));
                        }
                    }
                }

                groupRepo.Save(group);
                Uow.Commit();
                model.GroupId = group.Id;
                return RedirectToAction("ListGroups", "Group", new { @parentId = group.UserID });
            }
        }
コード例 #52
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface.
        /// </summary>
        /// <param name="moduleId">The Id of the module to be imported.</param>
        /// <param name="content">The content to be imported.</param>
        /// <param name="version">The version of the module to be imported.</param>
        /// <param name="userId">The Id of the user performing the import.</param>
        /// -----------------------------------------------------------------------------
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            var groups = new GroupRepository();
            var xmldnngroups = DotNetNuke.Common.Globals.GetContent(content, "Groups");
            var xmlGroupsNodeList = xmldnngroups.SelectNodes("Group");

            if (xmlGroupsNodeList == null) return;

            foreach (XmlNode xmldnngroup in xmlGroupsNodeList)
            {
                //Import a group
                var resourceGroupId = xmldnngroup.SelectSingleNode("ResourceGroupId");
                var resourceName = xmldnngroup.SelectSingleNode("ResourceName");

                if (resourceGroupId == null || resourceName == null) continue;

                var objdnngroup = new Group
                {
                    ResourceGroupId = new Guid(resourceGroupId.InnerText),
                    ResourceName = resourceName.InnerText,
                };

                groups.ImportCreate(objdnngroup);

                var resources = new ResourceRepository();
                var xmlResourcesNodeList = xmldnngroup.SelectNodes("Resources/Resource");

                //Import the resources of this group
                if (xmlResourcesNodeList == null) return;
                foreach (XmlNode xmldnnresource in xmlResourcesNodeList)
                {
                    var rGroupId = xmldnnresource.SelectSingleNode("ResourceGroupId");
                    var resourceKey = xmldnnresource.SelectSingleNode("ResourceKey");
                    var resourceValue = xmldnnresource.SelectSingleNode("ResourceValue");

                    if (rGroupId == null || resourceKey == null || resourceValue == null) continue;

                    var objdnnresource = new Resource
                    {
                        ResourceGroupId = new Guid(rGroupId.InnerText),
                        ResourceKey = resourceKey.InnerText,
                        ResourceValue = resourceValue.InnerText,

                    };

                    resources.Create(objdnnresource);
                }
            }
        }
コード例 #53
0
ファイル: RepositoryHelper.cs プロジェクト: oscar8326/BFCRM
 public static GroupRepository GetGroupRepository()
 {
     var repository = new GroupRepository();
     repository.UnitOfWork = GetUnitOfWork();
     return repository;
 }
コード例 #54
0
 public RepositoriesFactory(IDbContext context)
 {
     GroupRepository = new GroupRepository(context);
     PersonRepository = new PersonRepository(context);
     SubscriptionRepository = new SubscriptionRepository(context);
 }
コード例 #55
0
        public List<AssignedGroupsVM> PopulateAssignedGroups(User user)
        {
            List<AssignedGroupsVM> assignedGroups = new List<AssignedGroupsVM>();
            List<Group> groups = new GroupRepository().GetAll();

            if (user.Groups == null)
            {
                user.Groups = new List<Group>();
            }

            foreach (var g in groups)
            {
                assignedGroups.Add(new AssignedGroupsVM
                {
                    ID = g.ID,
                    Name = g.Name,
                    IsAssigned = user.Groups.Select(gr => gr.ID).Contains(g.ID)
                });
            }

            return assignedGroups;
        }
コード例 #56
0
        public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user)
        {
            SocialProfile socioprofile = new SocialProfile();
            //SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Api.SocialProfile.SocialProfile ApiObjSocialProfile = new Api.SocialProfile.SocialProfile();
            FacebookAccount fbAccount = new FacebookAccount();
            //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
            Api.FacebookFeed.FacebookFeed ApiObjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
            try
            {
                try
                {
                    fbAccount.AccessToken = accesstoken;
                }
                catch
                {
                }
                try
                {
                    fbAccount.EmailId = data["email"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.FbUserId = data["id"].ToString();
                }
                catch
                {
                }

                try
                {
                    fbAccount.ProfileUrl = data["link"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }


                try
                {
                    fbAccount.FbUserName = data["name"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.Friends = Convert.ToInt32(friends);
                }
                catch
                {
                }
                try
                {
                    fbAccount.Id = Guid.NewGuid();
                }
                catch
                {
                }
                fbAccount.IsActive = 1;
                try
                {
                    if (HttpContext.Current.Session["fbSocial"] != null)
                    {
                        if (HttpContext.Current.Session["fbSocial"] == "p")
                        {
                            //FacebookClient fbClient = new FacebookClient(accesstoken);
                            //int fancountPage = 0;
                            //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId });
                            //foreach (var friend in fancount.data)
                            //{
                            //    fancountPage = friend.fan_count;

                            //}
                            //fbAccount.Friends = Convert.ToInt32(fancountPage);
                            fbAccount.Type = "page";
                        }
                        else
                        {
                            fbAccount.Type = "account";
                        }
                        fbAccount.UserId = user;
                    }

                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                    {
                        try
                        {
                            fbAccount.UserId = user;
                            fbAccount.Type = "account";
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                }
                catch
                {
                }

                #region unused
                //if (HttpContext.Current.Session["login"] != null)
                //{
                //    if (HttpContext.Current.Session["login"].ToString().Equals("facebook"))
                //    {
                //        User usr = new User();
                //        UserRepository userrepo = new UserRepository();
                //        Registration regObject = new Registration();
                //        usr.AccountType = "free";
                //        usr.CreateDate = DateTime.Now;
                //        usr.ExpiryDate = DateTime.Now.AddMonths(1);
                //        usr.Id = Guid.NewGuid();
                //        usr.UserName = data["name"].ToString();
                //        usr.Password = regObject.MD5Hash(data["name"].ToString());
                //        usr.EmailId = data["email"].ToString();
                //        usr.UserStatus = 1;
                //        if (!userrepo.IsUserExist(data["email"].ToString()))
                //        {
                //            UserRepository.Add(usr);
                //        }
                //    }
                //} 
                #endregion
                try
                {
                    socioprofile.UserId = user;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileType = "facebook";
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileId = data["id"].ToString();
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileStatus = 1;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileDate = DateTime.Now;
                }
                catch
                {
                }
                try
                {
                    socioprofile.Id = Guid.NewGuid();
                }
                catch
                {
                }
                if (HttpContext.Current.Session["fbSocial"] != null)
                {
                    if (HttpContext.Current.Session["fbSocial"] == "p")
                    {

                        HttpContext.Current.Session["fbpagedetail"] = fbAccount;
                    }
                    else
                    {
                        if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                        {
                            fbrepo.addFacebookUser(fbAccount);
                            if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                            {
                               
                                socioprofilerepo.addNewProfileForUser(socioprofile);

                                GroupRepository objGroupRepository = new GroupRepository();
                                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                                Groups lstDetails = objGroupRepository.getGroupName(team.GroupId);
                                if (lstDetails.GroupName == "Socioboard")
                                {                                   
                                    TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();                                  
                                    TeamMemberProfile teammemberprofile = new TeamMemberProfile();
                                    teammemberprofile.Id = Guid.NewGuid();
                                    teammemberprofile.TeamId = team.Id;
                                    teammemberprofile.ProfileId = fbAccount.FbUserId;
                                    teammemberprofile.ProfileType = "facebook";
                                    teammemberprofile.StatusUpdateDate = DateTime.Now;

                                    objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);

                                }




                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }

                           

                        }
                        else
                        {
                            HttpContext.Current.Session["alreadyexist"] = fbAccount;
                            fbrepo.updateFacebookUser(fbAccount);
                            if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                            {
                                socioprofilerepo.addNewProfileForUser(socioprofile);
                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }
                        }

                    }
                }

                if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                {
                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook")
                    {
                        try
                        {
                            if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                            {
                                fbrepo.addFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            }
                            else
                            {
                                fbrepo.updateFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            
                            }
                            if (HttpContext.Current.Session["GroupName"] != null)
                            {
                                GroupProfile groupprofile = new GroupProfile();
                                GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
                                Groups group = (Groups)HttpContext.Current.Session["GroupName"];
                                groupprofile.Id = Guid.NewGuid();
                                groupprofile.GroupOwnerId = user;
                                groupprofile.ProfileId = socioprofile.ProfileId;
                                groupprofile.ProfileType = "facebook";
                                groupprofile.GroupId = group.Id;
                                groupprofile.EntryDate = DateTime.Now;
                                if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId))
                                {
                                    groupprofilerepo.AddGroupProfile(groupprofile);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
コード例 #57
0
ファイル: Controller.cs プロジェクト: NikTJ777/CSNuoHarness
        public void configure(String[] args)
        {
            // create app properties, using the default values as initial values
            appProperties = new Dictionary<String, String>(defaultProperties);

            // parse command line on top of defaults
            parseCommandLine(args, appProperties);

            // load properties from application.properties file over the defaults
            loadProperties(appProperties, PROPERTIES_PATH);

            // now load database properties file over the application and the defaults
            loadProperties(appProperties, DB_PROPERTIES_PATH);

            // parse the command line into app properties, as command line overrides all others
            parseCommandLine(args, appProperties);

            resolveReferences(appProperties);

            String[] keys = appProperties.Keys.ToArray();
            Array.Sort(keys);

            String helpOption;
            if (appProperties.TryGetValue("help", out helpOption) && "true".Equals(helpOption, StringComparison.InvariantCultureIgnoreCase)) {
                Console.Out.WriteLine("\nCSNuoTest [option=value [, option=value, ...] ]\nwhere <option> can be any of:\n");

                foreach (String key in keys) {
                    Console.Out.WriteLine(String.Format("{0}\t\t\t\t(default={1})", key, defaultProperties[key]));
                }

                Console.Out.WriteLine("\nHelp called - nothing to do; exiting.");
                Environment.Exit(0);
            }

            appLog.info("command-line properties: {0}",  string.Join(";", appProperties));

            StringBuilder builder = new StringBuilder(1024);
            builder.Append("\n***************** Resolved Properties ********************\n");
            foreach (String key in keys) {
                builder.AppendFormat("{0} = {1}\n", key, appProperties[key]);
            }
            appLog.info("{0}**********************************************************\n", builder.ToString());

            runTime = Int32.Parse(appProperties[RUN_TIME]) * Millis;
            averageRate = Single.Parse(appProperties[AVERAGE_RATE]);
            minViewAfterInsert = Int32.Parse(appProperties[MIN_VIEW_DELAY]);
            maxViewAfterInsert = Int32.Parse(appProperties[MAX_VIEW_DELAY]);
            timingSpeedup = Single.Parse(appProperties[TIMING_SPEEDUP]);
            minGroups = Int32.Parse(appProperties[MIN_GROUPS]);
            maxGroups = Int32.Parse(appProperties[MAX_GROUPS]);
            minData = Int32.Parse(appProperties[MIN_DATA]);
            maxData = Int32.Parse(appProperties[MAX_DATA]);
            burstProbability = Single.Parse(appProperties[BURST_PROBABILITY_PERCENT]);
            minBurst = Int32.Parse(appProperties[MIN_BURST]);
            maxBurst = Int32.Parse(appProperties[MAX_BURST]);
            maxQueued = Int32.Parse(appProperties[MAX_QUEUED]);
            initDb = Boolean.Parse(appProperties[DB_INIT]);
            queryOnly = Boolean.Parse(appProperties[QUERY_ONLY]);
            queryBackoff = Int32.Parse(appProperties[QUERY_BACKOFF]);
            maxRetry = Int32.Parse(appProperties[MAX_RETRY]);
            retrySleep = Int32.Parse(appProperties[RETRY_SLEEP]);

            String threadParam;
            int insertThreads = (appProperties.TryGetValue(INSERT_THREADS, out threadParam) ? Int32.Parse(threadParam) : 1);

            int queryThreads = (appProperties.TryGetValue(QUERY_THREADS, out threadParam) ? Int32.Parse(threadParam) : 1);

            if (maxViewAfterInsert > 0 && maxViewAfterInsert < minViewAfterInsert) {
                maxViewAfterInsert = minViewAfterInsert;
            }

            if (maxBurst <= minBurst) {
                appLog.info("maxBurst ({0}) <= minBurst ({1}); burst disabled", maxBurst, minBurst);
                burstProbability = minBurst = maxBurst = 0;
            }

            // filter out database properties, and strip off the prefix
            Dictionary<String, String> dbProperties = new Dictionary<String, String>();
            String dbPropertyPrefix = appProperties[DB_PROPERTY_PREFIX];
            if (! dbPropertyPrefix.EndsWith(".")) dbPropertyPrefix = dbPropertyPrefix + ".";

            foreach (String key in appProperties.Keys) {
                if (key.StartsWith(dbPropertyPrefix)) {
                    dbProperties[key.Substring(dbPropertyPrefix.Length)] = appProperties[key];
                }
            }

            //String insertIsolation = appProperties.getProperty(UPDATE_ISOLATION);
            //DataSource dataSource = new com.nuodb.jdbc.DataSource(dbProperties);
            SqlSession.init(dbProperties, insertThreads + queryThreads);

            SqlSession.CommunicationMode commsMode;
            if (!Enum.TryParse<SqlSession.CommunicationMode>(appProperties[COMMUNICATION_MODE], out commsMode))
                commsMode = SqlSession.CommunicationMode.SQL;
            SqlSession.globalCommsMode = commsMode;
            appLog.info("SqlSession.globalCommsMode set to {0}", commsMode);

            SqlSession.SpNamePrefix = appProperties[SP_NAME_PREFIX];

            ownerRepository = new OwnerRepository();
            ownerRepository.init();

            groupRepository = new GroupRepository();
            groupRepository.init();

            dataRepository = new DataRepository();
            dataRepository.init();

            eventRepository = new EventRepository(ownerRepository, groupRepository, dataRepository);
            eventRepository.init();

            if (!Enum.TryParse<TxModel>(appProperties[TX_MODEL], out txModel))
                txModel = TxModel.DISCRETE;

            if (!Enum.TryParse<SqlSession.Mode>(appProperties[BULK_COMMIT_MODE], out bulkCommitMode))
                bulkCommitMode = SqlSession.Mode.BATCH;

            //insertExecutor = Executors.newFixedThreadPool(insertThreads);
            //queryExecutor= Executors.newScheduledThreadPool(queryThreads);

            insertExecutor = new ThreadPoolExecutor<EventGenerator>("INSERT", insertThreads);
            queryExecutor = new ThreadPoolExecutor<EventViewTask>("QUERY", queryThreads);

            string checkOnly;
            if (appProperties.TryGetValue("check.config", out checkOnly) && checkOnly.Equals("true", StringComparison.InvariantCultureIgnoreCase)) {
                Console.Out.WriteLine("CheckConfig called - nothing to do; exiting.");
                Environment.Exit(0);
            }

            string silent;
            if (appProperties.TryGetValue("silent", out silent) && silent.Equals("true", StringComparison.InvariantCultureIgnoreCase)) {
                Logger.Silent = true;
            }
        }
コード例 #58
0
        public ActionResult List()
        {
            GroupsListVM model = new GroupsListVM();
            TryUpdateModel(model);

            GroupRepository groupRep = new GroupRepository();

            model.Groups = groupRep.GetAll();

            if (!String.IsNullOrEmpty(model.Search))
            {
                model.Search = model.Search.ToLower();
                model.Groups = model.Groups.Where(g => g.Name.ToLower().Contains(model.Search)).ToList();
            }

            model.Props = new Dictionary<string, object>();
            switch (model.SortOrder)
            {
                case "name_desc":
                    model.Groups = model.Groups.OrderByDescending(g => g.Name).ToList();
                    break;
                case "name_asc":
                default:
                    model.Groups = model.Groups.OrderBy(g => g.Name).ToList();
                    break;
            }

            PagingService.Prepare(model, ControllerContext, model.Groups);

            return View(model);
        }
コード例 #59
0
ファイル: RepositoryHelper.cs プロジェクト: oscar8326/BFCRM
 public static GroupRepository GetGroupRepository(IUnitOfWork unitOfWork)
 {
     var repository = new GroupRepository();
     repository.UnitOfWork = unitOfWork;
     return repository;
 }