Example #1
0
 // GET: Event/Delete/5
 public ActionResult Delete(int id)
 {
     using (EventManagerEntities dbModel = new EventManagerEntities())
     {
         return(View(dbModel.Events.Where(x => x.EventId == id).FirstOrDefault()));
     }
 }
Example #2
0
        public List <Participant> ListParticipantGender()
        {
            EventManagerEntities myDB       = new EventManagerEntities();
            List <Participant>   listGender = myDB.Participants.Where(s => s.ParticipantId > 0).ToList <Participant>();

            return(listGender);
        }
Example #3
0
 // GET: Event/Index
 public ActionResult Index()
 {
     using (EventManagerEntities dbModel = new EventManagerEntities())
     {
         return(View(dbModel.Events.ToList()));
     }
 }
Example #4
0
        public List <Participant> SearchBirthDate(DateTime date)

        {
            EventManagerEntities myDB          = new EventManagerEntities();
            List <Participant>   listBirthDate = myDB.Participants.Where(s => s.BirthDate == date).ToList <Participant>();

            return(listBirthDate);
        }
Example #5
0
        public List <Participant> SearchEmailAddress(string email)

        {
            EventManagerEntities myDB      = new EventManagerEntities();
            List <Participant>   listEmail = myDB.Participants.Where(s => s.EmailAddress == email).ToList <Participant>();

            return(listEmail);
        }
Example #6
0
        public List <Participant> SearchLastName(string lastName)

        {
            EventManagerEntities myDB         = new EventManagerEntities();
            List <Participant>   listLastName = myDB.Participants.Where(s => s.LastName == lastName).ToList <Participant>();

            return(listLastName);
        }
Example #7
0
        public string RemoveParticipant(int id)
        {
            EventManagerEntities myDB           = new EventManagerEntities();
            Participant          newParticipant = myDB.Participants.Where(s => s.ParticipantId == id).FirstOrDefault();

            myDB.Participants.Remove(newParticipant);
            myDB.SaveChanges();

            return("DELETE Success!");
        }
 public User Get(string name)
 {
     User user;
     using (var db = new EventManagerEntities())
     {
         using (var tx = db.Database.Connection.BeginTransaction(IsolationLevel.Unspecified))
         {
             user = db.Users.First(m => m.username == name);
             tx.Commit();
         }
     }
     return user;
 }
Example #9
0
 public User Get(string name)
 {
     User user;
     using (var db = new EventManagerEntities())
     {
         using (var tx = db.Database.Connection.BeginTransaction(IsolationLevel.Unspecified))
         {
             user = db.Users.First(m => m.username == name);
             if (user == null)
             {
                 return HttpNotFound();
             }
         }
     }
 }
Example #10
0
        public string PutParticipants(int ParticipantId, string FirstName, string LastName, string Gender, DateTime BirthDate, string EmailAddress)
        {
            EventManagerEntities myDB           = new EventManagerEntities();
            Participant          newParticipant = myDB.Participants.Where(s => s.ParticipantId == ParticipantId).FirstOrDefault();

            newParticipant.FirstName    = FirstName;
            newParticipant.LastName     = LastName;
            newParticipant.EmailAddress = EmailAddress;
            newParticipant.BirthDate    = BirthDate;
            newParticipant.Gender       = Gender;

            myDB.SaveChanges();

            return("PUT Success!");
        }
Example #11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Database.SetInitializer(new SampleData());
            Database.SetInitializer(new CreateDatabaseIfNotExists <EventManagerEntities>());

            var context = new EventManagerEntities();

            context.Database.Initialize(true);
        }
Example #12
0
 public ActionResult Create(Event e)
 {
     try
     {
         // TODO: Add insert logic here
         using (EventManagerEntities dbModel = new EventManagerEntities())
         {
             dbModel.Events.Add(e);
             dbModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #13
0
 public ActionResult Edit(int id, Event e)
 {
     try
     {
         // TODO: Add update logic here
         using (EventManagerEntities dbModel = new EventManagerEntities())
         {
             dbModel.Entry(e).State = EntityState.Modified;
             dbModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #14
0
        public VerificationResult VerifyUsernameAndPassword(string username, string password)
        {
            User user;
            using (var db = new EventManagerEntities())
            {
                user = db.Users.FirstOrDefault(m => m.username.ToUpper() == username.ToUpper());
                if (user == null)
                {
                    return VerificationResult.UserNameDoesNotExist;
                }
                else if (user.password != password)
                {
                    return VerificationResult.PasswordIncorrect;
                }

                return VerificationResult.Correct;
            }
        }
Example #15
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (EventManagerEntities dbModel = new EventManagerEntities())
         {
             Event e = dbModel.Events.Where(x => x.EventId == id).FirstOrDefault();
             dbModel.Events.Remove(e);
             dbModel.SaveChanges();
         }
         // TODO: Add delete logic here
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #16
0
        public string PostNewParticipant(string FirstName, string LastName, string Gender, DateTime BirthDate, string EmailAddress)
        {
            EventManagerEntities myDB           = new EventManagerEntities();
            Participant          newParticipant = new Participant();


            newParticipant.FirstName    = FirstName;
            newParticipant.LastName     = LastName;
            newParticipant.Gender       = Gender;
            newParticipant.BirthDate    = BirthDate;
            newParticipant.EmailAddress = EmailAddress;

            myDB.Participants.Add(newParticipant);

            myDB.SaveChanges();

            return("POST Success!");
        }
        public IPagedList<Event> GetEvents(int page, int pageSize, string sortOrder, string searchString)
        {
            IPagedList<Event> viewModel;
            searchString = searchString.ToUpper();
            using (var db = new EventManagerEntities())
            {
                using (var tx = db.Database.Connection.BeginTransaction(IsolationLevel.Unspecified))
                {
                    var events = from i in db.Events select i;

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        events = events.Where(i => i.title.ToUpper().Contains(searchString)
                                    || i.location.ToUpper().Contains(searchString)
                                    || i.Category.ToString().ToUpper().Contains(searchString)
                                    || i.eventDescription.ToUpper().Contains(searchString)
                                    || i.Type.ToString().ToUpper().Contains(searchString));
                    }
                    viewModel = events.ToPagedList(page, pageSize);
                    tx.Commit();
                    return viewModel;
                }
            }
        }
 public BaseRepository(EventManagerEntities context)
 {
     Context = context;
 }
 public EventRepository(EventManagerEntities context)
     : base(context)
 {
 }