Ejemplo n.º 1
0
        public void Perticipents(PollViewModel Data, List <string> inviteesIds)
        {
            try
            {
                PerticipentModel        member     = new PerticipentModel();
                List <PerticipentModel> MemberList = new List <PerticipentModel>();


                foreach (var id in inviteesIds)
                {
                    MemberList.Add(new PerticipentModel()
                    {
                        ActivityId    = Data.Id,
                        PerticipentId = id,
                        // AnswerId = 0
                    });
                }
                _data.Perticipents.AddRange(MemberList);
                _data.SaveChanges();
            }

            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public bool cust(string vote, int Id)
        {
            try
            {
                var poll = _data.PollingAndSyrvays.FirstOrDefault(x => x.Id == Id);

                if (poll.EndDate >= DateTime.Now && poll.StartDate <= DateTime.Now && (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (Current_User_id == poll.CreatorId || System.Web.HttpContext.Current.User.IsInRole("Administrator"))
                    {
                        var qus = _data.Questions.FirstOrDefault(y => y.ActivityId == poll.Id);
                        var ans = _data.Answers.First(z => z.QuestionId == qus.Id && z.Answer == vote);

                        if (poll.IsPublic)
                        {
                            PerticipentModel member = new PerticipentModel
                            {
                                ActivityId    = Id,
                                PerticipentId = Current_User_id,
                                AnswerId      = ans.Id
                            };
                            _data.Perticipents.Add(member);
                        }
                        else
                        {
                            var P = _data.Perticipents.FirstOrDefault(y => y.ActivityId == Id && y.PerticipentId == Current_User_id);

                            P.AnswerId = ans.Id;
                        }

                        _data.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            catch
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool CustSurvey(int[] Vote, int Id)
        {
            try
            {
                var y = _data.PollingAndSyrvays.FirstOrDefault(x => x.Id == Id);

                if (y.EndDate >= DateTime.Now && y.StartDate <= DateTime.Now && (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (Current_User_id == y.CreatorId || System.Web.HttpContext.Current.User.IsInRole("Administrator"))
                    {
                        List <PerticipentModel> members = new List <PerticipentModel>();
                        foreach (var i in Vote)
                        {
                            PerticipentModel member = new PerticipentModel
                            {
                                ActivityId    = Id,
                                PerticipentId = Current_User_id,
                                AnswerId      = i
                            };
                            members.Add(member);
                        }

                        _data.Perticipents.AddRange(members);
                        _data.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            catch
            {
                return(false);
            }
        }