Esempio n. 1
0
        public ActionResult Events()
        {
            EventsEventViewModel model  = new EventsEventViewModel();
            List <Event>         events = new List <Event>();

            using (var context = new NCContext.NCContext())
            {
                if (GlobalData.IsLoggedIn())
                {
                    string str     = GlobalData.GetEmail();
                    var    student = context.Students.Where(x => x.Email == str).FirstOrDefault();
                    if (student != null)
                    {
                        model.StudentId = student.Id;
                        var eventssubscribed = context.EventsSubscribers.Where(x => x.StudentId == student.Id).ToList();
                        if (eventssubscribed.Count > 0)
                        {
                            foreach (var e_subscribed in eventssubscribed)
                            {
                                var evet = context.Events.Where(x => x.Id == e_subscribed.EventId).FirstOrDefault();
                                if (evet != null)
                                {
                                    events.Add(evet);
                                }
                            }
                        }
                    }
                }
                model.SubscribedEvents  = events;
                model.Events            = context.Events.ToList();
                model.EventsSubscribers = context.EventsSubscribers.ToList();
            }
            return(View(model));
        }
Esempio n. 2
0
 public ActionResult UnSubscribe(string Email, int EventId)
 {
     if (!string.IsNullOrEmpty(Email) && EventId > 0)
     {
         using (var context = new NCContext.NCContext())
         {
             var student = context.Students.Where(x => x.Email == Email).FirstOrDefault();
             if (student != null)
             {
                 var e_subscribed = context.EventsSubscribers.Where(x => x.EventId == EventId && x.StudentId == student.Id).FirstOrDefault();
                 if (e_subscribed != null)
                 {
                     context.EventsSubscribers.Remove(e_subscribed);
                     context.SaveChanges();
                     var evet    = context.Events.Where(x => x.Id == EventId).FirstOrDefault();
                     var subject = "Event UnSubscribed";
                     var body    = "Hi, you have UnSubscribed from Event: " + evet.Title;
                     SendEmail(Email, body, subject);
                     return(RedirectToAction("Events"));
                 }
             }
         }
     }
     return(RedirectToAction("Events"));
 }
Esempio n. 3
0
 public ActionResult Category()
 {
     using (var Context = new NCContext.NCContext())
     {
         return(View(Context.EventCategories.ToList()));
     }
 }
Esempio n. 4
0
        public string ForgotPassword(string email)
        {
            string result = "";

            try
            {
                string resetCode = Guid.NewGuid().ToString();
                string verifyUrl = "/Account/ResetPassword/" + resetCode;
                var    link      = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl);
                using (var context = new NCContext.NCContext())
                {
                    var getuser = context.Students.Where(x => x.Email == email).FirstOrDefault();
                    if (getuser != null)
                    {
                        getuser.ResetPasswordCode = resetCode;
                        context.SaveChanges();
                        var subject = "Password Reset Request";
                        var body    = "Hi " + getuser.FName + ", You recently requested to reset your password for your account. Click the link to reset it. "

                                      + link + " If you did not request a password reset, please ignore this email. Thank you";
                        SendEmail(email, body, subject);
                        result = "true";
                    }
                    else
                    {
                        result = "Email is not valid";
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Esempio n. 5
0
        public string StatusChange(int Id, int status)
        {
            string result = "Internal Server Error";

            if (status > 0 && Id > 0)
            {
                try
                {
                    using (var context = new NCContext.NCContext())
                    {
                        var survey = context.Surveys.Where(x => x.Id == Id).FirstOrDefault();
                        if (survey != null)
                        {
                            survey.Status = status;
                            context.Entry(survey).State = EntityState.Modified;
                            context.SaveChanges();
                            var student = context.Students.Where(x => x.Id == survey.StudentId).FirstOrDefault();
                            var subject = "Event Subscribed";
                            var body    = "Hi, thank you for giving your time and playing the survey as a result you win the cofee card.";
                            SendEmail(student.Email, body, subject);
                            result = "true";
                        }
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
            }
            return(result);
        }
Esempio n. 6
0
 public ActionResult Feedbacks()
 {
     using (var context = new NCContext.NCContext())
     {
         return(View(context.Feedbacks.ToList()));
     }
 }
Esempio n. 7
0
        public string AddEntry()
        {
            string result = "";
            var    email  = GlobalData.GetEmail();

            if (email != null)
            {
                using (var context = new NCContext.NCContext())
                {
                    var student = context.Students.Where(x => x.Email == email).FirstOrDefault();
                    var num     = context.Surveys.Where(x => x.StudentId == student.Id).FirstOrDefault();
                    if (num == null)
                    {
                        Survey survey = new Survey();
                        survey.StudentId = student.Id;
                        context.Surveys.Add(survey);
                        context.SaveChanges();
                        int id = survey.Id;
                        survey.SurveyNo = id;
                        context.SaveChanges();
                        return("true");
                    }
                    else
                    {
                        return("You already take survey");
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
 public ActionResult Student()
 {
     using (var context = new NCContext.NCContext())
     {
         return(View(context.Students.ToList()));
     }
 }
Esempio n. 9
0
 public ActionResult Promotions()
 {
     using (var context = new NCContext.NCContext())
     {
         return(View(context.Promotions.ToList()));
     }
 }
Esempio n. 10
0
 public ActionResult EditCategory(int Id)
 {
     using (var context = new NCContext.NCContext())
     {
         return(View(context.EventCategories.Where(x => x.Id == Id).FirstOrDefault()));
     }
 }
Esempio n. 11
0
 public ActionResult Login(string Email, string Password)
 {
     using (var context = new NCContext.NCContext())
     {
         if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password))
         {
             var Isuser = context.Users.Where(x => x.Email.ToLower() == Email.ToLower() && x.Password == Password).FirstOrDefault();
             if (Isuser != null)
             {
                 if (Isuser.Role == "admin")
                 {
                     FormsAuthentication.SetAuthCookie(Email.ToLower(), true);
                     return(RedirectToAction("Dashboard", "Admin"));
                 }
                 else if (Isuser.Role == "student")
                 {
                     GlobalData.SetEmail(Email);
                     FormsAuthentication.SetAuthCookie(Email.ToLower(), true);
                     GlobalData.SetLoginStatus(true);
                     return(RedirectToAction("Index", "Index"));
                 }
             }
         }
     }
     ViewBag.error = "false";
     GlobalData.SetLoginStatus(false);
     GlobalData.SetEmail("");
     return(View());
 }
Esempio n. 12
0
        public string ChangeStatus(int Id, int status)
        {
            string result = "Internal Server Error";

            if (status > 0 && Id > 0)
            {
                try
                {
                    using (var context = new NCContext.NCContext())
                    {
                        var post = context.Posts.Where(x => x.Id == Id).FirstOrDefault();
                        if (post != null)
                        {
                            post.ApprovalStatus       = status;
                            post.Date                 = DateTime.Now;
                            context.Entry(post).State = EntityState.Modified;
                            context.SaveChanges();
                            result = "true";
                        }
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
            }
            return(result);
        }
Esempio n. 13
0
 public ActionResult Annoucments()
 {
     using (var context = new NCContext.NCContext())
     {
         var list = context.Surveys.Where(x => x.Status == 1).Include(x => x.Student).ToList();
         return(View(list));
     }
 }
Esempio n. 14
0
 public ActionResult Index()
 {
     using (var context = new NCContext.NCContext())
     {
         var promotions = context.Promotions.Where(x => x.Status == 1).ToList();
         return(View(promotions));
     }
 }
Esempio n. 15
0
 public string EditCategory(EventCategory eventCategory)
 {
     using (var context = new NCContext.NCContext())
     {
         context.Entry(eventCategory).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return("true");
     }
 }
Esempio n. 16
0
        public ActionResult Surveys()
        {
            using (var context = new NCContext.NCContext())
            {
                var list = context.Surveys.Include(x => x.Student).ToList();

                return(View(list));
            }
        }
Esempio n. 17
0
 public ActionResult EditEvent(int Id)
 {
     using (var context = new NCContext.NCContext())
     {
         GetEditEventViewModels model = new GetEditEventViewModels();
         model.Event           = context.Events.Where(x => x.Id == Id).FirstOrDefault();
         model.EventCategories = context.EventCategories.ToList();
         return(View(model));
     }
 }
Esempio n. 18
0
        public string EditPromotion(Promotion promotion)
        {
            string result = "";

            using (var context = new NCContext.NCContext())
            {
                context.Entry(promotion).State = EntityState.Modified;
                context.SaveChanges();
                result = "true";
            }
            return(result);
        }
Esempio n. 19
0
        public string AddPromotion(Promotion promotion)
        {
            string result = "";

            using (var context = new NCContext.NCContext())
            {
                context.Promotions.Add(promotion);
                context.SaveChanges();
                result = "true";
            }
            return(result);
        }
Esempio n. 20
0
        public ActionResult EditPromotion(int Id)
        {
            Promotion promotion = new Promotion();

            using (var context = new NCContext.NCContext())
            {
                if (Id > 0)
                {
                    promotion = context.Promotions.Where(x => x.Id == Id).FirstOrDefault();
                }
            }
            return(View(promotion));
        }
Esempio n. 21
0
 public string EditPost(Post post)
 {
     if (post != null)
     {
         using (var context = new NCContext.NCContext())
         {
             context.Entry(post).State = EntityState.Modified;
             context.SaveChanges();
             return("true");
         }
     }
     return("Internal Server Error");
 }
Esempio n. 22
0
 public string DeleteStudent(int Id)
 {
     using (var context = new NCContext.NCContext())
     {
         var student = context.Students.Where(x => x.Id == Id).FirstOrDefault();
         if (student != null)
         {
             context.Students.Remove(student);
             context.SaveChanges();
             return("true");
         }
     }
     return("Internal Server Error");
 }
Esempio n. 23
0
        public string Feedback(Feedback feedback)
        {
            string result = "";

            if (feedback != null)
            {
                using (var context = new NCContext.NCContext())
                {
                    context.Feedbacks.Add(feedback);
                    context.SaveChanges();
                    result = "true";
                }
            }
            return(result);
        }
Esempio n. 24
0
        public ActionResult EditPost(int Id)
        {
            GetEditPostViewModel model = new GetEditPostViewModel();

            using (var context = new NCContext.NCContext())
            {
                var post = context.Posts.Where(x => x.Id == Id).FirstOrDefault();
                if (post != null)
                {
                    post.ApprovalStatus   = 0;
                    model.Post            = post;
                    model.EventCategories = context.EventCategories.ToList();
                }
            }
            return(View(model));
        }
Esempio n. 25
0
        public string DeletePromotion(int Id)
        {
            string result = "";

            using (var context = new NCContext.NCContext())
            {
                var promotion = context.Promotions.Where(x => x.Id == Id).FirstOrDefault();
                if (promotion != null)
                {
                    context.Promotions.Remove(promotion);
                    context.SaveChanges();
                    result = "true";
                }
            }
            return(result);
        }
Esempio n. 26
0
 public string AddCategory(EventCategory eventCategory)
 {
     using (var context = new NCContext.NCContext())
     {
         if (eventCategory != null)
         {
             context.EventCategories.Add(eventCategory);
             context.SaveChanges();
             return("true");
         }
         else
         {
             return("Name Field is Required");
         }
     }
 }
Esempio n. 27
0
        public string DeleteFeedback(int Id)
        {
            string result = "";

            using (var context = new NCContext.NCContext())
            {
                var feedback = context.Feedbacks.Where(x => x.Id == Id).FirstOrDefault();
                if (feedback != null)
                {
                    context.Feedbacks.Remove(feedback);
                    context.SaveChanges();
                    result = "true";
                }
            }
            return(result);
        }
Esempio n. 28
0
 public string AddEvent(Event evnt)
 {
     using (var context = new NCContext.NCContext())
     {
         if (evnt != null)
         {
             context.Events.Add(evnt);
             context.SaveChanges();
             return("true");
         }
         else
         {
             return("All Fields are Required");
         }
     }
 }
Esempio n. 29
0
        public ActionResult BlogPosts()
        {
            List <Post> posts = new List <Post>();

            using (var context = new NCContext.NCContext())
            {
                var psts = context.Posts.Include(x => x.Student).Include(x => x.EventCategory).ToList();
                foreach (var post in psts)
                {
                    post.EventCategory = context.EventCategories.Where(x => x.Id == post.EventCategoryId).FirstOrDefault();
                    post.Student       = context.Students.Where(x => x.Id == post.StudentId).FirstOrDefault();
                    posts.Add(post);
                }
            }
            return(View(posts));
        }
Esempio n. 30
0
 public string EditEvent(Event evnt)
 {
     if (evnt != null)
     {
         using (var context = new NCContext.NCContext())
         {
             context.Entry(evnt).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             return("true");
         }
     }
     else
     {
         return("Internal Server Error");
     }
 }