public IActionResult CreateEvent(CreateEventViewModel input)
        {
            var   context = new OnlineWebPortalDbContext();
            Event myEvent = new Event();

            if (ModelState.IsValid)
            {
                try
                {
                    myEvent.EventDate   = input.EventDate;
                    myEvent.EventName   = input.EventName;
                    myEvent.Description = input.Description;
                    context.Add(myEvent);
                    context.SaveChanges();
                    TempData["successMessage"] = " Event has been created successfully";
                    return(RedirectToAction("EventList", "Event"));
                }
                catch (Exception ex)
                {
                    TempData["failMessage"] = " Oops! Something went wrong" + ex.Message;
                    return(RedirectToAction("EventList", "Event"));
                }
            }
            return(View());
        }
        public IActionResult EmailNotification(int id)
        {
            //MimeMessage message = new MimeMessage();
            //MailboxAddress from = new MailboxAddress("User", "*****@*****.**");
            //message.From.Add(from);
            //MailboxAddress to = new MailboxAddress("Leader", "*****@*****.**");
            //message.To.Add(to);
            //message.Subject = "This is email subject";
            //BodyBuilder bodyBuilder = new BodyBuilder();
            //bodyBuilder.HtmlBody = "<h1>Hello World!</h1>";
            //bodyBuilder.TextBody = "Hello World!";
            //message.Body = bodyBuilder.ToMessageBody();
            //SmtpClient client = new SmtpClient();
            //client.Connect("Mail.yahoo.com", 587, true);
            //client.Authenticate("*****@*****.**", "goldbook497");
            //client.Send(message);
            //client.Disconnect(true);
            //client.Dispose();


            var context = new OnlineWebPortalDbContext();
            var join    = new RegUserChurchGroup();

            if (ModelState.IsValid)
            {
                var user = context.RegUsers.Where(u => u.FirstName == User.Identity.Name).Single();
                join.ChurchGroupID = id;
                join.RegUserID     = user.ID;
                context.Add(join);
                context.SaveChanges();
                ViewData["message"] = "Registration was successful!";
                return(RedirectToAction("FindGroup", "Group"));
            }
            return(RedirectToAction("Portal", "Home"));
        }
        public IActionResult CreateEnquiry(CreateEnquiryViewModel input)
        {
            var     context = new OnlineWebPortalDbContext();
            Enquiry enquiry = new Enquiry();

            if (ModelState.IsValid && (input.EnquiryType != null))
            {
                try
                {
                    enquiry.EnquiryType = input.EnquiryType;
                    enquiry.EnquiryDate = input.EnquiryDate;
                    enquiry.EnquiryBody = input.EnquiryBody;
                    enquiry.RegUser     = input.RegUser;
                    context.Add(enquiry);
                    context.SaveChanges();
                    TempData["successMessage"] = " Your enquiry has been sent successfully";
                    return(RedirectToAction("CreateEnquiry", "Enquiry"));
                }
                catch (Exception ex)
                {
                    TempData["failMessage"] = " Oops! Something went wrong" + ex.Message;
                    return(RedirectToAction("CreateEnquiry", "Enquiry"));
                }
            }
            return(View());
        }
        public IActionResult DeleteGroup(int id)
        {
            var context = new OnlineWebPortalDbContext();
            var groupId = context.ChurchGroups.FirstOrDefault(e => e.ID == id);

            context.ChurchGroups.Remove(groupId);
            context.SaveChanges();
            return(RedirectToAction("FindGroup", "Group"));
        }
        public IActionResult Delete(int id)
        {
            var context = new OnlineWebPortalDbContext();
            var eventId = context.Events.FirstOrDefault(e => e.ID == id);

            context.Events.Remove(eventId);
            context.SaveChanges();
            return(RedirectToAction("EventList", "Event"));
        }
        public IActionResult Delete(int id)
        {
            var context = new OnlineWebPortalDbContext();
            var enq     = context.Enquiries.FirstOrDefault(e => e.ID == id);

            context.Enquiries.Remove(enq);
            context.SaveChanges();
            return(RedirectToAction("EnquiryList", "Enquiry"));
        }
        public IActionResult AddMember(AddGroupMemberViewModel input)
        {
            var context = new OnlineWebPortalDbContext();
            var join    = new RegUserChurchGroup();

            if (ModelState.IsValid)
            {
                join.ChurchGroupID = input.ChurchGroupID;
                join.RegUserID     = input.RegUserID;
                context.Add(join);
                context.SaveChanges();
                ViewData["message"] = "Registration was successful!";
                return(RedirectToAction("FindGroup", "Group"));
            }
            return(RedirectToAction("Portal", "Home"));
        }
Example #8
0
        public IActionResult DeleteUserAccount(int id)
        {
            var context = new OnlineWebPortalDbContext();

            try
            {
                var acc = context.RegUsers.SingleOrDefault(a => a.ID == id);
                context.RegUsers.Remove(acc);
                context.SaveChanges();
                TempData["message"] = "Member has been deleted!";
                return(RedirectToAction("Portal", "Home"));
            }
            catch (Exception ex)
            {
                TempData["message"] = " Oops! We have a problem here" + ex.Message;
                return(RedirectToAction("Users", "User"));
            }
        }
Example #9
0
        public IActionResult Register(RegisterViewModel input)
        {
            var db = new OnlineWebPortalDbContext();

            if (ModelState.IsValid)
            {
                RegUser user = new RegUser();
                user.FirstName        = input.FirstName;
                user.LastName         = input.LastName;
                user.Username         = input.Username;
                user.Password         = input.Password;
                user.Roles            = "Member";
                user.Sex              = input.Sex;
                user.MaritalStatus    = input.MaritalStatus;
                user.DateOFBirth      = input.DateOFBirth;
                user.PhoneNumber      = input.PhoneNumber;
                user.Email            = input.Email;
                user.MemType          = input.MemType;
                user.DateOfMembership = input.DateOfMembership;

                try
                {
                    db.RegUsers.Add(user);
                    db.SaveChanges();
                    TempData["message"] = "Registration was successful!";
                    if (User.Identity.IsAuthenticated == true)
                    {
                        return(RedirectToAction("Users", "User"));
                    }
                    else
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                }
                catch (Exception ex)
                {
                    TempData["message"] = " Oops! We have a problem here" + ex.Message;
                    return(RedirectToAction("Register", "Account"));
                }
            }
            return(View());
        }
        public IActionResult EditGroup(int id, GroupEditViewModel input)
        {
            var context = new OnlineWebPortalDbContext();
            var group   = context.ChurchGroups.FirstOrDefault(e => e.ID == id);

            if (group != null && ModelState.IsValid)
            {
                group.GroupName        = input.GroupName;
                group.GroupDescription = input.GroupDescription;
                group.MeetingDay       = input.MeetingDay;
                group.StartTime        = input.StartTime;
                group.EndTime          = input.EndTime;
                group.Location         = input.Location;
                group.LeaderName       = input.LeaderName;
                group.LeaderProfile    = input.LeaderProfile;
                context.SaveChanges();
                return(RedirectToAction("FindGroup", "Group"));
            }
            return(View(group));
        }
        public IActionResult CreateGroup(GroupCreateViewModel input)
        {
            var         context = new OnlineWebPortalDbContext();
            ChurchGroup group   = new ChurchGroup();

            if (ModelState.IsValid && (input.GroupName != null))
            {
                group.GroupName        = input.GroupName;
                group.GroupDescription = input.GroupDescription;
                group.MeetingDay       = input.MeetingDay;
                group.StartTime        = input.StartTime;
                group.EndTime          = input.EndTime;
                group.Location         = input.Location;
                group.LeaderName       = input.LeaderName;
                group.LeaderProfile    = input.LeaderProfile;
                context.Add(group);
                context.SaveChanges();
                return(RedirectToAction("FindGroup", "Group"));
            }
            return(View());
        }
Example #12
0
        public IActionResult EditAccount(int id, RegisterViewModel input)
        {
            var context = new OnlineWebPortalDbContext();
            var user    = context.RegUsers.FirstOrDefault(e => e.ID == id);

            if (user != null && ModelState.IsValid)
            {
                user.FirstName        = input.FirstName;
                user.LastName         = input.LastName;
                user.Username         = input.LastName;
                user.Password         = input.Password;
                user.Sex              = input.Sex;
                user.MaritalStatus    = input.MaritalStatus;
                user.DateOFBirth      = input.DateOFBirth;
                user.PhoneNumber      = input.PhoneNumber;
                user.Email            = input.Email;
                user.MemType          = input.MemType;
                user.DateOfMembership = input.DateOfMembership;
                context.SaveChanges();
                return(RedirectToAction("Portal", "Home"));
            }
            return(View(user));
        }
Example #13
0
        public IActionResult CreateGiving(CreatePaymentViewModel input)
        {
            var     context = new OnlineWebPortalDbContext();
            Payment payment = new Payment();

            if (ModelState.IsValid && (input.PaymentType != null))
            {
                var usr  = User.Identity.Name;
                var user = context.RegUsers.Where(u => u.FirstName + " " + u.LastName == usr).SingleOrDefault();


                payment.PaymentType = input.PaymentType;
                payment.PaymentDate = input.PaymentDate;
                payment.Amount      = input.Amount;
                payment.RegUserID   = user.ID;
                //payment.RegUserID = 2;


                context.Add(payment);
                context.SaveChanges();
                return(RedirectToAction("OnlineGiving", "Giving"));
            }
            return(View());
        }