Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["adminid"] != null)
            {
                if (!IsPostBack)
                {
                    if (Session["PostIDForEdit"] != null)
                    {
                        int id = Session["PostIDForEdit"].ToString().ToInt();
                        Session.Add("newPostIDForEdit", id);
                        Session.Remove("PostIDForEdit");
                        ArticleRepository repArt = new ArticleRepository();
                        GroupsRepository  repo   = new GroupsRepository();
                        Article           art    = repArt.FindeArticleByID(id);
                        title.Text    = art.Title;
                        Abstract.Text = art.Abstract;
                        editor1.Text  = art.Content;
                        KeyWords.Text = art.KeyWords;
                        Tags.Text     = art.Tags;
                        SelectedSubGroups.DataSource     = repo.FindSubGroupsOfAnArticle(id);
                        SelectedSubGroups.DataTextField  = "Title";
                        SelectedSubGroups.DataValueField = "GroupID";
                        SelectedSubGroups.DataBind();
                        for (int i = 0; i < SelectedSubGroups.Items.Count; i++)
                        {
                            if (SelectedSubGroups.Items[i].Value == "-1")
                            {
                                SelectedSubGroups.Items[i].Text = "گروه : " + SelectedSubGroups.Items[i].Text;
                            }
                        }

                        DDLGroups.DataSource     = repo.LoadAllGroups();
                        DDLGroups.DataTextField  = "Title";
                        DDLGroups.DataValueField = "GroupID";
                        DDLGroups.DataBind();
                        DDLGroups.Items.Insert(0, new ListItem("یک گروه انتخاب کنید", "-2"));
                        oldPhoto.ImageUrl = art.ImgFirstPage;
                    }
                    else
                    {
                        Response.Redirect("/Admin/ManageBlogs");
                    }
                }
            }
            else
            {
                Response.Redirect("/AdminLogin");
            }
        }
Esempio n. 2
0
 public Group Save()
 {
     using (GroupsRepository repo = new GroupsRepository(DataContext))
     {
         if (_id == 0)
         {
             _id = repo.Insert(Name);
         }
         else
         {
             repo.Update(Id, Name);
         }
         return(this);
     }
 }
Esempio n. 3
0
 protected void subgroup()
 {
     diverror.InnerHtml = "";
     if (ddlSubGroups.SelectedValue != "-2")
     {
         ArticleRepository artrep   = new ArticleRepository();
         List <Article>    articles = artrep.ReturnArticlesByCategory(ddlSubGroups.SelectedValue.ToInt());
         if (articles.Count != 0)
         {
             gvPosts.DataSource = null;
             gvPosts.DataBind();
             gvPosts.DataSource = OnlineTools.ToDataTable(articles);
             gvPosts.DataBind();
         }
         else
         {
             gvPosts.DataSource = null;
             gvPosts.DataBind();
             diverror.InnerHtml = " در این بخش مقاله ای وجود ندارد! ";
         }
     }
     else
     {
         if (ddlGroups.SelectedValue != "-2")
         {
             GroupsRepository  Groupsrepo  = new GroupsRepository();
             List <int>        subgroupsid = Groupsrepo.getSubGroupsIDByFatherID(ddlGroups.SelectedValue.ToInt());
             ArticleRepository artrep      = new ArticleRepository();
             List <Article>    articles    = artrep.ReturnArticlesByCategory(subgroupsid);
             if (articles.Count != 0)
             {
                 gvPosts.DataSource = null;
                 gvPosts.DataSource = OnlineTools.ToDataTable(articles);
                 gvPosts.DataBind();
             }
             else
             {
                 gvPosts.DataSource = null;
                 gvPosts.DataBind();
                 diverror.InnerHtml = " در این بخش مقاله ای وجود ندارد! ";
             }
         }
         else
         {
             group();
         }
     }
 }
        public void Given_Group_When_DeleteGroupAsync_Then_ShouldBeTrue()
        {
            RunOnDatabase(context =>
            {
                // ARRANGE


                context.Roles.Add(Role.Create("student"));
                context.SaveChanges();

                var userType = context.Roles.FirstOrDefault();
                if (userType != null)
                {
                    var user = User.Create(
                        "User first name",
                        "User last name",
                        "User",
                        "*****@*****.**",
                        "parola"
                        );
                    context.Users.Add(user);
                }
                context.SaveChanges();

                var userId = context.Users.FirstOrDefault();

                var groupRepository = new GroupsRepository(context);
                if (userId == null)
                {
                    return;
                }
                var group = Group.Create(

                    "A2",
                    "grupa din anul III",
                    userId.Id

                    );

                context.Add(@group);
                context.SaveChanges();

                // ACT
                var result = groupRepository.DeleteAsync(@group.Id);
                // ASSERT
                result.Result.Should().Be(true);
            });
        }
Esempio n. 5
0
 static Unit()
 {
     _context = new MyAppDbContext("MyAppConnStr");
     DepartmentsRepository  = new DepartmentsRepository(_context);
     TeachersRepository     = new TeachersRepository(_context);
     SubjectsRepository     = new SubjectsRepository(_context);
     SpecialitiesRepository = new SpecialitiesRepository(_context);
     GroupsRepository       = new GroupsRepository(_context);
     PhonesRepository       = new PhonesRepository(_context);
     StudentsRepository     = new StudentsRepository(_context);
     AudiencesRepository    = new AudiencesRepository(_context);
     AudLectRepository      = new AudLectRepository(_context);
     LectionsRepository     = new LectionsRepository(_context);
     MarksRepository        = new MarksRepository(_context);
     TeachSubjRepository    = new TeachSubjRepository(_context);
 }
Esempio n. 6
0
        private void fillServises()
        {
            GroupsRepository gr     = new GroupsRepository();
            List <Group>     groups = new List <Group>();

            groups = gr.LoadListAllGroups();
            Random        random = new Random();
            List <string> icons  = new List <string>();

            foreach (Group gp in groups)
            {
                string name = "";
                if (icons.Count != 0)
                {
                    int index = random.Next(icons.Count);
                    name = icons[index];
                    icons.RemoveAt(index);
                }
                else
                {
                    icons = new List <string> {
                        "fa-building"
                    };
                    int index = random.Next(icons.Count);
                    name = icons[index];
                    icons.RemoveAt(index);
                }

                ourServises.InnerHtml += "<div class='item '><div class='row m0 service'><div class='row m0 innerRow item'><div><i class='fa " + name + "'></i><div class='serviceName'>" + gp.Title + "</div><div class='item-overlay left'><ul><li class='liLeft'><input type='button' onclick=\"window.location='/Blogs/" + gp.GroupID + "';\" value='مقالات'  class='btnLeftService'></li><li class='liRight'><input type='button' onclick=\"$('#modal" + gp.GroupID + "').modal('show');\"  value='زیر گروه ها'  class='btnRightService'></li></ul></div></div></div></div></div>";
                List <Group> templist = new List <Group>();
                templist = gr.LoadListSubGroup(gp.GroupID);
                string buttons = "";
                if (templist.Count != 0)
                {
                    foreach (Group sgp in templist)
                    {
                        buttons += " <input type='button' class='btn btn-warning' onclick=\"window.location='/Blogs/" + gp.GroupID + "/" + sgp.GroupID + "';\" style='margin: 5px' value='" + sgp.Title + "'/>";
                    }
                    modalsdiv.InnerHtml += "<div class='modal fade' id='modal" + gp.GroupID + "' tabindex='-1' role='dialog' aria-labelledby='modalAskSubmitUpdate-label' aria-hidden='true'> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button> <h4 class='modal-title'> <span class='glyphicon glyphicon-warning-sign'></span> زیر گروه های " + gp.Title + " </h4> </div><div class='modal-body' style='direction: rtl'> " + buttons + " </div><div class='modal-footer'> </div></div></div></div>";
                }
                else
                {
                    modalsdiv.InnerHtml += "<div class='modal fade' id='modal" + gp.GroupID + "' tabindex='-1' role='dialog' aria-labelledby='modalAskSubmitUpdate-label' aria-hidden='true'> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button> <h4 class='modal-title'> <span class='glyphicon glyphicon-warning-sign'></span> زیر گروه های " + gp.Title + " </h4> </div><div class='modal-body' style='direction: rtl'> <span style='color: red;font-weight: bold;'>این گروه زیر گروهی ندارد !</span> </div><div class='modal-footer'> </div></div></div></div>";
                }
            }
        }
Esempio n. 7
0
        protected void btnSaveSubGroupChane_Click(object sender, EventArgs e)
        {
            GroupsRepository repgp = new GroupsRepository();

            if (!String.IsNullOrEmpty(SubNewName.Text))
            {
                Group ngr = new Group();
                ngr       = repgp.FindGroup(SubIDHolder.Text.ToInt());
                ngr.Title = SubNewName.Text;

                if (repgp.Savegp(ngr))
                {
                    gvSubGroups.DataSource = null;
                    gvSubGroups.DataBind();
                    if (ddlGroups.SelectedValue != "-2")
                    {
                        gvSubGroups.DataSource = repgp.LoadSubGroup(ddlGroups.SelectedValue.ToInt());
                    }
                    else
                    {
                        gvSubGroups.DataSource = repgp.LoadAllSubGroups();
                    }

                    gvSubGroups.DataBind();
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(@"<script type='text/javascript'>");
                    sb.Append("$('#modalShowGroupDetails').modal('hide');");
                    sb.Append(@"</script>");
                    ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                        "ModalScript", sb.ToString(), false);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت با موفقیت انجام شد');", true);
                    SubNewName.Text = "";
                }
                else
                {
                    SubNewName.Text = "";
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(@"<script type='text/javascript'>");
                    sb.Append("$('#modalShowGroupDetails').modal('hide');");
                    sb.Append(@"</script>");
                    ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                        "ModalScript", sb.ToString(), false);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت با خطا مواجه شد !');", true);
                }
            }
        }
Esempio n. 8
0
        public bool GrpMem(Domain.Socioboard.Domain.User user)
        {
            GroupsRepository       grpRep    = new GroupsRepository();
            GroupMembersRepository grpMemRep = new GroupMembersRepository();
            UserRepository         userRepo  = new UserRepository();

            // Domain.Socioboard.Domain.User user = userRepo.getUserInfoByEmail(Email);
            //foreach (var user in lstUser)
            //{
            try
            {
                List <Domain.Socioboard.Domain.Groups> lstGroups = grpRep.getAlluserGroups(user.Id);
                foreach (var item in lstGroups)
                {
                    try
                    {
                        if (user != null)
                        {
                            Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers();
                            grpMember.Id      = Guid.NewGuid();
                            grpMember.Emailid = user.EmailId;
                            grpMember.Groupid = item.Id.ToString();
                            grpMember.IsAdmin = true;
                            grpMember.Status  = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
                            grpMember.Userid  = item.UserId.ToString();
                            if (!grpMemRep.checkMemberExistsingroup(grpMember.Groupid, grpMember.Userid))
                            {
                                grpMemRep.AddGroupMemeber(grpMember);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                    }
                }
            }
            catch (Exception e) { }


            //}

            return(true);
        }
Esempio n. 9
0
 static Unit()
 {
     _context                  = new MyAppDbContext("MyAppConnStr");
     AddressesRepository       = new AddressesRepository(_context);
     ClassroomsRepository      = new ClassroomsRepository(_context);
     DepartmentsRepository     = new DepartmentsRepository(_context);
     GroupsRepository          = new GroupsRepository(_context);
     GroupTimetablesRepository = new GroupTimetablesRepository(_context);
     MarksRepository           = new MarksRepository(_context);
     PairTimetablesRepository  = new PairTimetablesRepository(_context);
     PhonesRepository          = new PhonesRepository(_context);
     SpecialitiesRepository    = new SpecialitiesRepository(_context);
     StudentsRepository        = new StudentsRepository(_context);
     SubjectsRepository        = new SubjectsRepository(_context);
     TeachSubjsRepository      = new TeachSubjsRepository(_context);
     TeachersRepository        = new TeachersRepository(_context);
     TimetablesRepository      = new TimetablesRepository(_context);
 }
Esempio n. 10
0
        public Boolean validatePermissionsAdministrator()
        {
            if (cUser.id == 0 || cUser == null)
            {
                return(false);
            }

            this.group.id = uRepository.findUserById(user).idGroup;
            gRepository   = new GroupsRepository(this.group);
            var result = gRepository.findGroupById();

            if (result.name.TrimEnd() == "Administracao")
            {
                return(true);
            }

            return(false);
        }
Esempio n. 11
0
        public async Task <IActionResult> Index()
        {
            IEnumerable <UserTask> tasks = await TasksRepository.GetAll();

            IEnumerable <TaskGroup> groups = await GroupsRepository.GetAll();

            foreach (var task in tasks)
            {
                if (!groups.Any(g => g.UserTasks != null && g.UserTasks.Any(t => t.Id == task.Id)))
                {
                    await TasksRepository.Delete(task.Id);
                }
            }

            ViewData.Model = (await GroupsRepository.GetAll()).ToList();

            return(View());
        }
Esempio n. 12
0
        public Boolean validatePermissionsFinancial()
        {
            if (cUser == null)
            {
                return(false);
            }

            this.group.id = uRepository.findUserById(user).idGroup;
            gRepository   = new GroupsRepository(this.group);
            var result = gRepository.findGroupById();

            if (result.name == "Financeiro")
            {
                return(true);
            }

            return(false);
        }
        public void Given_Group_When_NewGroupIsAdded_Then_ShouldHaveOneGroupInDatabase()
        {
            RunOnDatabase(context => {
                // ARRANGE


                context.Roles.Add(Role.Create("student"));
                context.SaveChanges();

                var userType = context.Roles.FirstOrDefault();
                if (userType != null)
                {
                    var user = User.Create(
                        "User first name",
                        "User last name",
                        "User",
                        "*****@*****.**",
                        "parola"
                        );
                    context.Users.Add(user);
                }
                context.SaveChanges();

                var userId = context.Users.FirstOrDefault();

                var groupRepository = new GroupsRepository(context);
                if (userId == null)
                {
                    return;
                }
                var group = Group.Create(

                    "A2",
                    "grupa din anul III",
                    userId.Id

                    );
                var groupInserted = groupRepository.InsertAsync(@group).Result;
                // ACT
                var result = groupRepository.GetByIdAsync(groupInserted.Id);
                // ASSERT
                result.Should().NotBe(null);
            });
        }
Esempio n. 14
0
        public async Task <HttpResponseMessage> GetGroupImage(string groupid)
        {
            GroupsRepository groupsRepository = new GroupsRepository(graphClient);

            try
            {
                byte[] imgData = await groupsRepository.GetGroupPhoto(groupid);

                MemoryStream        ms       = new MemoryStream(imgData);
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StreamContent(ms);
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/png");
                return(response);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 15
0
 public UnitOfWork(DataContext context)
 {
     _context      = context;
     Users         = new UsersRepository(_context);
     Photos        = new PhotosRepository(_context);
     Groups        = new GroupsRepository(_context);
     Memberships   = new MembershipsRepository(_context);
     Auths         = new AuthRepository(_context);
     Comments      = new CommentsRepository(_context);
     Achievements  = new AchievementsRepository(_context);
     Cities        = new CitiesRepository(_context);
     Countries     = new CountriesRepository(_context);
     Locations     = new LocationsRepository(_context);
     Matchdays     = new MatchdaysRepository(_context);
     MatchStatuses = new MatchStatusesRepository(_context);
     Friends       = new FriendsRepository(_context);
     Messages      = new MessagesRepository(_context);
     Chats         = new ChatsRepository(_context);
 }
Esempio n. 16
0
        public async Task <ActionResult> Delete([FromHeader] string Authentication, [FromQuery] string Id)
        {
            if (SessionManager.GetSessionState(Authentication) != SessionManager.SessionState.Authorized)
            {
                return(Unauthorized());
            }
            SessionInfo sessionInfo = SessionManager.GetSessionInfo(Authentication);

            if (sessionInfo == null)
            {
                return(Unauthorized());
            }

            int groupId = 0;

            if (!int.TryParse(Id, out groupId) || groupId <= 0)
            {
                return(BadRequest());
            }

            using (UnitOfWork uow = new UnitOfWork())
            {
                MembershipRepository        membershipRepository = new MembershipRepository(uow);
                IEnumerable <MembershipDTO> memberships          = await membershipRepository.GetAllByGroupId(groupId);

                if (memberships == null)
                {
                    return(NotFound());
                }

                foreach (var membership in memberships)
                {
                    await membershipRepository.Remove(membership.Id);
                }

                GroupsRepository groupsRepository = new GroupsRepository(uow);
                await groupsRepository.Remove(groupId);

                uow.Commit();
            }

            return(Ok());
        }
Esempio n. 17
0
        public async Task <ActionResult> Index()
        {
            var groupsRepository = new GroupsRepository(graphClient);

            try
            {
                var groups = await groupsRepository.GetGroups();

                return(View(groups));
            }
            catch (Exception ex)
            {
                if (ex is AdalException)
                {
                    throw ex;
                }
                return(RedirectToAction("Index", "Error", new { message = ex.Message }));
            }
        }
        public async Task <ActionResult> Index(string channelId)
        {
            try
            {
                var accessTokenSharePoint = await AadHelper.GetAccessTokenForSharePoint();

                var accessTokenMSGraph = await AadHelper.GetAccessTokenForMicrosoftGraph();

                var sharePointRepository    = new VideoChannelRepository(accessTokenSharePoint);
                var groupsRepository        = new GroupsRepository(graphClient);
                var subscriptionsRepository = new SubscriptionsRepository(graphClient, this.Session, HttpRuntime.Cache);

                var channel = await sharePointRepository.GetChannel(channelId);

                var videos = await sharePointRepository.GetChannelVideos(channelId);

                var groups = await groupsRepository.GetGroups();

                var viewModel = new VideoListViewModel
                {
                    ChannelId    = channelId,
                    ChannelTitle = channel.Title,
                    Videos       = videos,
                    Groups       = groups
                };

                // integration of the webhooks example
                Microsoft.Graph.Subscription result = await subscriptionsRepository.CreateOrReuseSubscription();

                return(View(viewModel));
            }
            catch (Exception ex)
            {
                if (ex is AdalException)
                {
                    // let the ActionFilterAttribute take care of it
                    throw ex;
                }

                return(RedirectToAction("Index", "Error", new { message = ex.Message }));
            }
        }
Esempio n. 19
0
        public async Task <IActionResult> RemoveTaskGroup(int id)
        {
            TaskGroup group = await GroupsRepository.GetByID(id);

            if (group.UserTasks == null)
            {
                group.UserTasks = new List <UserTask>();
            }

            while (group.UserTasks.Any())
            {
                await TasksRepository.Delete((group.UserTasks.ToList())[0].Id);
            }

            await GroupsRepository.Update(group);

            await GroupsRepository.Delete(id);

            return(RedirectToAction("Index"));
        }
        public async Task <(bool, Guid)> InsertGroup(Models.UI.CUD.FirstMessageModel model)
        {
            try
            {
                UsersRepository.DisableLazyLoading();
                Group actualG = model.group.ToActualGroup();
                GroupsRepository.InsertEntry(actualG);
                var users = await UsersRepository.GetManyBy(u => model.group.GroupUsers.Select(gu => gu.Name).Contains(u.UserName));

                actualG.Users = users.CreateGroupUsers(actualG, model.group.MessageUsers.First().RealMsg, model.currentId);
                await GroupsRepository.SaveChangesAsync();

                return(true, actualG.Id);
            }
            catch (Exception e)
            {
                Logger.LogError("Exception at InsertGroup", e);
                return(false, Guid.NewGuid());
            }
        }
Esempio n. 21
0
        public static List <Group> getGroups()
        {
            DataTable        dt      = new DataTable();
            List <Group>     objDept = new List <Group>();
            GroupsRepository jg      = new GroupsRepository();

            dt = jg.LoadAllGroups();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    objDept.Add(new Group
                    {
                        GroupID  = Convert.ToInt32(dt.Rows[i][0]),
                        Title    = dt.Rows[i][1].ToString(),
                        FatherID = Convert.ToInt32(dt.Rows[i][2])
                    });
                }
            }
            return(objDept);
        }
Esempio n. 22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["adminid"] != null)
     {
         if (!IsPostBack)
         {
             btnSave.Enabled    = false;
             diverror.InnerText = "هیچ گروهی انتخاب نشده!";
             GroupsRepository repo = new GroupsRepository();
             DDLGroups.DataSource     = repo.LoadAllGroups();
             DDLGroups.DataTextField  = "Title";
             DDLGroups.DataValueField = "GroupID";
             DDLGroups.DataBind();
             DDLGroups.Items.Insert(0, new ListItem("یک گروه انتخاب کنید", "-2"));
         }
     }
     else
     {
         Response.Redirect("/AdminLogin");
     }
 }
Esempio n. 23
0
 public UnitOfWork(RoleplayContext context)
 {
     Context                        = context;
     AccountsRepository             = new AccountsRepository(context);
     BuildingsRepository            = new BuildingsRepository(context);
     CharactersRepository           = new CharactersRepository(context);
     CrimeBotsRepository            = new CrimeBotsRepository(context);
     GroupsRepository               = new GroupsRepository(context);
     GroupWarehouseItemsRepository  = new GroupWarehouseItemsRepository(context);
     GroupWarehouseOrdersRepository = new GroupWarehouseOrdersRepository(context);
     ItemsRepository                = new ItemsRepository(context);
     PenaltiesRepository            = new PenaltiesRepository(context);
     TelephoneContactsRepository    = new TelephoneContactsRepository(context);
     TelephoneMessagesRepository    = new TelephoneMessagesRepository(context);
     VehiclesRepository             = new VehiclesRepository(context);
     WorkersRepository              = new WorkersRepository(context);
     ZonesRepository                = new ZonesRepository(context);
     GroupRanksRepository           = new GroupRankRepository(context);
     TicketsRepository              = new TicketsRepository(context);
     ItemTemplatesRepository        = new ItemTemplatesRepository(context);
 }
Esempio n. 24
0
        public async Task <ActionResult> Add([FromHeader] string Authentication, [FromBody] GroupDTO group)
        {
            if (SessionManager.GetSessionState(Authentication) != SessionManager.SessionState.Authorized)
            {
                return(Unauthorized());
            }
            SessionInfo sessionInfo = SessionManager.GetSessionInfo(Authentication);

            if (sessionInfo == null)
            {
                return(Unauthorized());
            }

            if (string.IsNullOrEmpty(group.Name) || string.IsNullOrEmpty(group.DefaultCurrency) ||
                !Currencies.CurrenciesList.Contains(group.DefaultCurrency))
            {
                return(BadRequest());
            }

            group.CreatedDate = DateTime.Now;

            using (UnitOfWork uow = new UnitOfWork())
            {
                GroupsRepository groupsRepository = new GroupsRepository(uow);
                group.Id = await groupsRepository.Add(group);

                MembershipDTO membership = new MembershipDTO
                {
                    UserId  = sessionInfo.UserId,
                    GroupId = group.Id,
                    Status  = 3
                };
                MembershipRepository membershipRepository = new MembershipRepository(uow);
                await membershipRepository.Add(membership);

                uow.Commit();
            }

            return(Ok());
        }
        public TeachersSubjects(Staff staff)
        {
            InitializeComponent();
            this.staff       = staff;
            repository       = new SubjectsTeachersRepository();
            groupsRepository = new GroupsRepository();
            usersRepository  = new UsersRepository();

            groups   = groupsRepository.GetJustGroups();
            teachers = usersRepository.GetJustStaff();

            for (int a = 0; a < groups.Count; a++)
            {
                AddGroupComboBox.Items.Add(groups[a].Name);
            }


            for (int a = 0; a < teachers.Count; a++)
            {
                AddTeacherComboBox.Items.Add(teachers[a].FirstName + " " + teachers[a].LastName);
            }
        }
Esempio n. 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //load posts

                ProjectsRepository ArtRep   = new ProjectsRepository();
                List <Project>     Articles = ArtRep.AllProjects();
                fillUl(Articles);

                //load ddls
                ddlSubGroups.Enabled = false;

                GroupsRepository repo = new GroupsRepository();
                ddlGroups.DataSource     = repo.LoadAllGroups();
                ddlGroups.DataTextField  = "Title";
                ddlGroups.DataValueField = "GroupID";
                ddlGroups.DataBind();
                ddlGroups.Items.Insert(0, new ListItem("همه گروه ها", "-2"));
                ddlSubGroups.Items.Insert(0, new ListItem("همه زیرگروه ها", "-2"));
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Dodawanie nowej grupy
        /// </summary>
        /// <param name="name"></param>
        /// <param name="tag"></param>
        /// <param name="type"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public static GroupEntity Create(string name, string tag, GroupType type, Color color)
        {
            GroupModel groupModel = new GroupModel
            {
                Workers   = new List <WorkerModel>(),
                Name      = name,
                Tag       = tag,
                GroupType = type,
                Color     = color.ToHex()
            };

            RoleplayContext ctx = Singletons.RoleplayContextFactory.Create();

            using (GroupsRepository repository = new GroupsRepository(ctx))
            {
                repository.Insert(groupModel);
                repository.Save();
            }

            GroupEntityFactory factory = new GroupEntityFactory();

            return(factory.Create(groupModel));
        }
Esempio n. 28
0
 public UnitOfWork(VegaContext context)
 {
     _context             = context;
     Clients              = new ClientRepository(_context);
     Users                = new UserRepository(_context);
     Supplier             = new SupplierRepository(_context);
     Component            = new ComponentRepository(_context);
     ImportingInvoice     = new ImportingInvoiceRepository(_context);
     UGroup               = new GroupsRepository(_context);
     FabricationOrder     = new FabricationOrderRepository(_context);
     Expence              = new ExpenceRepository(_context);
     ExpenceCat           = new  ExpenceCatRepository(_context);
     GroupPermission      = new  GroupPermissionRepository(_context);
     Permission           = new PermissionRepository(_context);
     Sequence             = new SequenceRepository(_context);
     Nomenclature         = new NomenclatureRepository(_context);
     NomenclatureSequence = new NomenclatureSequenceRepository(_context);
     Color                = new ColorRepository(_context);
     SellingInvoices      = new SellingInvoicesRepository(_context);
     RawMaterials         = new RawMaterialsRepository(_context);
     UsedRawMaterial      = new UsedRawMaterialRepository(_context);
     ProgressionChecks    = new ProgressionChecksRepository(_context);
 }
Esempio n. 29
0
        public void GetItemTest()
        {
            // to run test even if db is empty
            var spec = new Speciality {
                Name = "TestAutomation"
            };

            _context.Specialities.Add(spec);

            var repo = new GroupsRepository(_context);
            var item = new Group {
                Name = "TPP-18-3", Speciality = _context.Specialities.FirstOrDefault()
            };

            repo.AddItem(item);
            int Id = _context.Groups.FirstOrDefault(x => x.Name == item.Name && x.Speciality.Id == item.Speciality.Id).Id;

            Assert.AreEqual(item.Name, repo.GetItem(Id).Name);
            Assert.AreEqual(item.Speciality, repo.GetItem(Id).Speciality);

            _context.Groups.Remove(item);
            _context.Specialities.Remove(spec);
        }
Esempio n. 30
0
        protected void ddlSubGroups_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlSubGroups.SelectedValue != "-2")
            {
                ArticleRepository artrep   = new ArticleRepository();
                List <Article>    articles = artrep.ReturnArticlesByCategory(ddlSubGroups.SelectedValue.ToInt());
                if (articles.Count != 0)
                {
                    fillUl(articles);
                }
                else
                {
                    UlArticles.InnerHtml = " <li class='danger'>در این بخش مقاله ای وجود ندارد!</li> ";
                }
            }
            else
            {
                if (ddlGroups.SelectedValue != "-2")
                {
                    GroupsRepository  Groupsrepo  = new GroupsRepository();
                    List <int>        subgroupsid = Groupsrepo.getSubGroupsIDByFatherID(ddlGroups.SelectedValue.ToInt());
                    ArticleRepository artrep      = new ArticleRepository();
                    List <Article>    articles    = artrep.ReturnArticlesByCategory(subgroupsid);
                    if (articles.Count != 0)
                    {
                        fillUl(articles);
                    }
                    else
                    {
                        UlArticles.InnerHtml = " <li class='danger'>در این بخش مقاله ای وجود ندارد!</li> ";
                    }
                }
            }

            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "run()", true);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "myFunction()", true);
        }
    protected void btnImport_Click(object sender, EventArgs e)
    {
        btnImport.Enabled = false;
        fuImport.Enabled = false;
        btnImport.Text = "Processing...";
        if (!fuImport.HasFile)
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Chọn file để nhập');", true);
        else
        {
            string ext = fuImport.FileName.Substring(fuImport.FileName.LastIndexOf('.') + 1).ToLower();
            if (!ext.Equals("xls") && !ext.Equals("xlsx"))
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Định dạng file nhập ko đúng');", true);
            else
            {
                string newFileName = Guid.NewGuid().ToString("N") + "." + ext;
                string pathToFile = Server.MapPath("~\\Import") + "\\" + newFileName;
                fuImport.SaveAs(pathToFile);
                try
                {
                    ObjLogin adm = (ObjLogin)Session["objLogin"];

                    int smsquota = int.Parse(ConfigurationManager.AppSettings["SMSQuota"]);
                    double expiredDateConfig = Convert.ToDouble(ConfigurationManager.AppSettings["ExpiredDate"]);
                    DateTime expiredDate = Convert.ToDateTime(DateTime.Now.AddDays(expiredDateConfig));

                    var GRepo = new GroupsRepository();
                    var RegionRepo = new RegionsRepository();
                    var AreaRepo = new AreasRepository();
                    var LocalRepo = new LocalsRepository();
                    var ChRepo = new ChannelRepository();
                    var SaleRepo = new SalesmanRepository();
                    var CLogRepo = new CustomersLogRepository();
                    var CRepo = new CustomersRepository();
                    var CTRepo = new CustomerTypeRepository();
                    var DisRepo = new DistrictsRepository();
                    var proviceRepo = new ProvincesRepository();
                    var sectionRepo = new SectionRepository();

                    SpreadsheetInfo.SetLicense("E24D-D739-F65A-4E00");
                    ExcelFile ef = new ExcelFile();
                    ef.LoadXls(pathToFile);
                    ExcelWorksheet ws = ef.Worksheets[0];

                    for (int i = 2; i < ws.Rows.Count; i++)
                    {
                        try
                        {
                            vwMasterList vmMasterItem = new vwMasterList(ws.Rows[i].Cells[4].Value.ToString(),
                                                                ws.Rows[i].Cells[5].Value.ToString(),
                                                                ws.Rows[i].Cells[6].Value.ToString(),
                                                                ws.Rows[i].Cells[7].Value.ToString(),
                                                                ws.Rows[i].Cells[8].Value.ToString(),
                                                                ws.Rows[i].Cells[9].Value.ToString(),
                                                                ws.Rows[i].Cells[10].Value.ToString(),
                                                                ws.Rows[i].Cells[11].Value.ToString(),
                                                                ws.Rows[i].Cells[12].Value.ToString(),
                                                                ws.Rows[i].Cells[13].Value.ToString(),
                                                                ws.Rows[i].Cells[14].Value.ToString(),
                                                                ws.Rows[i].Cells[15].Value.ToString(),
                                                                ws.Rows[i].Cells[17].Value.ToString(),
                                                                ws.Rows[i].Cells[18].Value.ToString(),
                                                                ws.Rows[i].Cells[19].Value.ToString(),
                                                                ws.Rows[i].Cells[20].Value.ToString(),
                                                                ws.Rows[i].Cells[22].Value.ToString(),
                                                                ws.Rows[i].Cells[23].Value.ToString(),
                                                                ws.Rows[i].Cells[24].Value.ToString());

                            // Add Group - Region - Area - Local
                            var groupId = GRepo.Import("", vmMasterItem.Group, "");
                            var regionId = RegionRepo.Import("", vmMasterItem.Region, "", groupId);
                            var areaId = AreaRepo.Import("", vmMasterItem.Area, "", regionId);
                            var localId = LocalRepo.Import("", vmMasterItem.Local, "", areaId);

                            // Add section
                            var sectionId = sectionRepo.Import(vmMasterItem.Area);

                            // Add Province
                            var provinceId = proviceRepo.Import(vmMasterItem.Local, sectionId);

                            // Add District
                            var districtId = DisRepo.Import(vmMasterItem.Local, provinceId);

                            // Add Channel
                            ChRepo.Insert("", vmMasterItem.Channel1, 0);
                            ChRepo.Insert("", vmMasterItem.Channel2, ChRepo.GetChannelIdByName(vmMasterItem.Channel1));
                            ChRepo.Insert("", vmMasterItem.Channel3, ChRepo.GetChannelIdByName(vmMasterItem.Channel2));

                            // Add Customer Type
                            CTRepo.Add("", vmMasterItem.Channel3);

                            // Add Salesmen
                            var tromId = SaleRepo.ImportSalesmen("", vmMasterItem.TROM, "", (int)SalesmenRole.TROM, smsquota, expiredDate, -1);
                            var tpsId = SaleRepo.ImportSalesmen("", vmMasterItem.TPS, "", (int)SalesmenRole.TPS, smsquota, expiredDate, tromId);
                            var tprId = SaleRepo.ImportSalesmen("", vmMasterItem.TPR, "", (int)SalesmenRole.TPR, smsquota, expiredDate, tpsId);

                            var eromId = SaleRepo.ImportSalesmen("", vmMasterItem.EROM, "", (int)SalesmenRole.EROM, smsquota, expiredDate, -1);
                            var pss1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS1, "", (int)SalesmenRole.PSS1, smsquota, expiredDate, eromId);
                            var psr1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR1, "", (int)SalesmenRole.PSR1, smsquota, expiredDate, pss1Id);

                            var erom2Id = SaleRepo.ImportSalesmen("", vmMasterItem.EROM2, "", (int)SalesmenRole.EROM2, smsquota, expiredDate, -1);
                            var pss2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS2, "", (int)SalesmenRole.PSS2, smsquota, expiredDate, erom2Id);
                            var psr2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR2, "", (int)SalesmenRole.PSR2, smsquota, expiredDate, pss2Id);

                            // Add Salesgroup - salesregion - salesarea - saleslocal
                            ImportSalesGroup(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, GRepo, groupId);
                            ImportSalesRegion(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, RegionRepo, regionId);
                            ImportSalesArea(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, AreaRepo, areaId);
                            ImportSalesLocal(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, LocalRepo, localId);

                            // Add Customer - Customer Log
                            int CustomerId = CRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "",
                                CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3),
                                ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now,
                                true, false);
                            CLogRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "",
                                CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3),
                                ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now,
                                true, CustomerId, false, 0, adm.Id, string.Empty);

                            lstCustomer.Add(vmMasterItem);
                        }
                        catch (Exception ex)
                        {
                            // write log here => TBD
                        }
                    }

                    CustomerList.DataSource = lstCustomer;
                    CustomerList.DataBind();
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('" + ex.Message + "');", true);
                }
                finally
                {

                }

            }
        }
        btnImport.Enabled = true;
        fuImport.Enabled = true;
        btnImport.Text = "Import";
    }
 public IHttpActionResult DeleteUserDetails(string user)
 {
     GroupsRepository _GroupsRepository=new GroupsRepository();
     GroupMembersRepository _GroupMembersRepository = new GroupMembersRepository();
     GroupProfileRepository _GroupProfileRepository = new GroupProfileRepository();
     TaskRepository _TaskRepository = new TaskRepository();
     TaskCommentRepository _TaskCommentRepository = new TaskCommentRepository();
     InboxMessagesRepository _InboxMessagesRepository=new InboxMessagesRepository();
     FacebookAccountRepository _FacebookAccountRepository=new FacebookAccountRepository();
     GoogleAnalyticsAccountRepository _GoogleAnalyticsAccountRepository=new GoogleAnalyticsAccountRepository();
     GooglePlusAccountRepository _GooglePlusAccountRepository=new GooglePlusAccountRepository();
     InstagramAccountRepository _InstagramAccountRepository=new InstagramAccountRepository();
     LinkedInAccountRepository _LinkedInAccountRepository=new LinkedInAccountRepository();
     LinkedinCompanyPageRepository _LinkedinCompanyPageRepository=new LinkedinCompanyPageRepository();
     ScheduledMessageRepository _ScheduledMessageRepository=new ScheduledMessageRepository();
     SocialProfilesRepository _SocialProfilesRepository = new SocialProfilesRepository();
     TwitterAccountRepository _TwitterAccountRepository=new TwitterAccountRepository();
     TumblrAccountRepository _TumblrAccountRepository = new TumblrAccountRepository();
     YoutubeAccountRepository _YoutubeAccountRepository = new YoutubeAccountRepository();
     YoutubeChannelRepository _YoutubeChannelRepository = new YoutubeChannelRepository();
     try
     {
         Domain.Socioboard.Domain.User _User = userrepo.getUserInfoByEmail(user);
         if (_User != null)
         {
             List<Domain.Socioboard.Domain.Groups> lstGroups = _GroupsRepository.getAllGroups(_User.Id);
             foreach (Domain.Socioboard.Domain.Groups item_group in lstGroups)
             {
                 int i = _GroupMembersRepository.DeleteGroupMember(item_group.Id.ToString());
                 int j = _GroupProfileRepository.DeleteAllGroupProfile(item_group.Id);
                 bool rt = _GroupProfileRepository.DeleteGroupReport(item_group.Id);
                 int k = _TaskRepository.DeleteTaskOfGroup(item_group.Id);
             }
             int g = _GroupMembersRepository.DeleteGroupMemberByUserId(user);
             int h = _GroupsRepository.DeleteGroupsByUserid(_User.Id);
             int l = _TaskCommentRepository.DeleteTaskCommentByUserid(_User.Id);
             int m = _InboxMessagesRepository.DeleteInboxMessages(_User.Id);
             int n = _FacebookAccountRepository.DeleteAllFacebookAccount(_User.Id);
             int o = _GoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(_User.Id);
             int p = _GooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(_User.Id);
             int q = _InstagramAccountRepository.DeleteInstagramAccountByUserid(_User.Id);
             int r = _LinkedInAccountRepository.DeleteLinkedInAccountByUserid(_User.Id);
             int s = _LinkedinCompanyPageRepository.DeleteLinkedinCompanyPage(_User.Id);
             int t = _ScheduledMessageRepository.DeleteScheduledMessageByUserid(_User.Id);
             int u = _SocialProfilesRepository.DeleteSocialProfileByUserid(_User.Id);
             int v = _TwitterAccountRepository.DeleteTwitterAccountByUserid(_User.Id);
             int w = _TumblrAccountRepository.DeletetumblraccountByUserid(_User.Id);
             int x = _YoutubeAccountRepository.DeleteYoutubeAccount(_User.Id);
             int y = _YoutubeChannelRepository.DeleteYoutubeChannelByUserid(_User.Id);
             int z = userrepo.DeleteUser(_User.Id);
         }
         else {
             return Ok(false);
         }
     }
     catch (Exception ex)
     {
         return BadRequest(ex.StackTrace);
     }
     return Ok(true);
 }
Esempio n. 33
0
        private static Domain.Socioboard.Domain.Groups AddGroupByUserId(Guid userId)
        {
            Domain.Socioboard.Domain.Groups groups = new Domain.Socioboard.Domain.Groups();
            GroupsRepository objGroupRepository = new GroupsRepository();
            UserRepository userRepo = new UserRepository();
            GroupMembersRepository grpMemberRepo = new GroupMembersRepository();

            groups.Id = Guid.NewGuid();
            groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
            groups.UserId = userId;
            groups.EntryDate = DateTime.UtcNow;

            objGroupRepository.AddGroup(groups);

            Domain.Socioboard.Domain.User objUser = userRepo.getUsersById(groups.UserId);
            Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers();
            grpMember.Id = Guid.NewGuid();
            grpMember.Groupid = groups.Id.ToString();
            grpMember.Userid = groups.UserId.ToString();
            grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
            grpMember.Emailid = objUser.EmailId;
            grpMember.IsAdmin = true;
            grpMemberRepo.AddGroupMemeber(grpMember);


            return groups;
        }
Esempio n. 34
0
        private static Domain.Socioboard.Domain.Groups AddGroupByUserId(Guid userId)
        {
            Domain.Socioboard.Domain.Groups groups = new Domain.Socioboard.Domain.Groups();
            GroupsRepository objGroupRepository = new GroupsRepository();

            groups.Id = Guid.NewGuid();
            groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
            groups.UserId = userId;
            groups.EntryDate = DateTime.Now;

            objGroupRepository.AddGroup(groups);
            return groups;
        }
    private static void ImportSalesGroup(int tromId, int tpsId, int tprId, int eromId, int pss1Id, int psr1Id, int erom2Id, int pss2Id, int psr2Id,
                                         GroupsRepository GRepo, int groupId)
    {
        GRepo.AddSalesmenGroup(tprId, groupId);
        GRepo.AddSalesmenGroup(tpsId, groupId);
        GRepo.AddSalesmenGroup(tromId, groupId);

        GRepo.AddSalesmenGroup(psr1Id, groupId);
        GRepo.AddSalesmenGroup(pss1Id, groupId);
        GRepo.AddSalesmenGroup(eromId, groupId);

        GRepo.AddSalesmenGroup(psr2Id, groupId);
        GRepo.AddSalesmenGroup(pss2Id, groupId);
        GRepo.AddSalesmenGroup(erom2Id, groupId);
    }
        public bool GrpMem(Domain.Socioboard.Domain.User user) 
        {
            GroupsRepository grpRep = new GroupsRepository();
            GroupMembersRepository grpMemRep = new GroupMembersRepository();
            UserRepository userRepo = new UserRepository();
           // Domain.Socioboard.Domain.User user = userRepo.getUserInfoByEmail(Email);
            //foreach (var user in lstUser) 
            //{
                try 
                {
                    List<Domain.Socioboard.Domain.Groups> lstGroups = grpRep.getAlluserGroups(user.Id);
                    foreach (var item in lstGroups)
                    {
                        try
                        {
                            if (user != null)
                            {
                                Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers();
                                grpMember.Id = Guid.NewGuid();
                                grpMember.Emailid = user.EmailId;
                                grpMember.Groupid = item.Id.ToString();
                                grpMember.IsAdmin = true;
                                grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
                                grpMember.Userid = item.UserId.ToString();
                                if (!grpMemRep.checkMemberExistsingroup(grpMember.Groupid, grpMember.Userid))
                                {
                                    grpMemRep.AddGroupMemeber(grpMember);
                                }

                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            logger.Error(ex.StackTrace);
                        }


                    }
                }
                catch (Exception e) { }
               

            //}
            
            return true;

        }