Ejemplo n.º 1
0
        public async Task Create_new_MeetUp_from_new_meetupDto_has_ids_and_same_values()
        {
            //arrange
            AppDbContext      appDbContext  = AppDbContextMocker.GetAppDbContext("test_2");
            IMeetUpRepository _repo         = new MeetUpRepository(appDbContext);
            IMeetUpManager    meetUpManager = new MeetUpManager();

            CreateMeetUpDto newM = new CreateMeetUpDto()
            {
                Date        = DateTime.Now,
                CostPerSeat = 0M,
                Location    = "New Location",
                SeatRows    = 10,
                SeatsPerRow = 10
            };

            MeetUp mu = meetUpManager.CreateNewMeetUp(newM.Date.Value, newM.Location, newM.SeatRows, newM.SeatsPerRow, newM.CostPerSeat.Value);

            //act
            mu = _repo.Create(mu);
            await _repo.SaveChangesAsync();

            //assert
            Assert.True(mu.Id == 3);
            Assert.Equal(newM.Location, mu.Location);
            Assert.Equal(3, mu.SeatGrid.Id);
            Assert.Equal(100, mu.SeatGrid.Seats?.Count);

            //clean up otherwise the other test will complain about key tracking.
            await appDbContext.DisposeAsync();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <MeetUp> > PostMeetUp(MeetUp meetUp)
        {
            _context.MeetUps.Add(meetUp);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMeetUp", new { id = meetUp.Id_meetup }, meetUp));
        }
Ejemplo n.º 3
0
        public async Task Updating_meetup_from_untracked_should_update()
        {
            //arrange
            MeetUp meetUp = new MeetUp()
            {
                Id          = 1,
                CostPerSeat = 1M,
                Location    = "Updated Location",
                Date        = DateTime.Now.AddDays(2)
            };
            AppDbContext      appDbContext = AppDbContextMocker.GetAppDbContext("test_3");
            IMeetUpRepository _repo        = new MeetUpRepository(appDbContext);

            //act
            _repo.Update(meetUp);
            await _repo.SaveChangesAsync();

            var getEnt = _repo.FetchById(meetUp.Id);

            //assert
            Assert.Equal(meetUp.Id, getEnt.Id);
            Assert.Equal(meetUp.Location, getEnt.Location);//default location is Location 1
            Assert.True(getEnt.SeatGrid != null);


            await appDbContext.DisposeAsync();
        }
Ejemplo n.º 4
0
        public MeetUp Update(MeetUp updatedMeetUp)
        {
            var entyti = ctx.MeetUps.Attach(updatedMeetUp);

            entyti.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return(updatedMeetUp);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutMeetUp(int id, MeetUp meetUp)
        {
            if (id != meetUp.Id_meetup)
            {
                return(BadRequest());
            }

            _context.Entry(meetUp).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MeetUpExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit_my_meetup(int?id)
        {
            MeetUp meet = await db.MeetUps.FirstOrDefaultAsync(p => p.Id_meetup == id);

            ViewBag.lat = meet.lat;
            ViewBag.lng = meet.lng;
            return(View(meet));
        }
Ejemplo n.º 7
0
        public static void SeedAppDbContext(this AppDbContext appDbContext)
        {
            seatId     = 5;
            seatGridId = 1;
            //populate the database with some seed values for testing
            var meetUp1 = new MeetUp()
            {
                Id          = 1,
                CostPerSeat = 0M,
                Location    = "Location 1",
                Date        = DateTime.Now.AddDays(2),
                SeatGrid    = GenerateSeatGrid(10, 10)
            };

            var meetUp2 = new MeetUp()
            {
                Id          = 2,
                CostPerSeat = 0M,
                Location    = "Location 2",
                Date        = DateTime.Now.AddDays(32),
                SeatGrid    = GenerateSeatGrid(10, 10)
            };

            appDbContext.MeetUps.AddRange(meetUp1, meetUp2);

            var booking1 = new Booking()
            {
                Id           = 1,
                BookingEmail = "*****@*****.**",
                Seats        = new List <Seat>()
                {
                    new Seat {
                        Id = 1, PersonName = "person1", ReferenceEmail = "*****@*****.**", SeatLabel = "A1"
                    },
                    new Seat {
                        Id = 2, PersonName = "person2", ReferenceEmail = "*****@*****.**", SeatLabel = "A2"
                    },
                    new Seat {
                        Id = 3, PersonName = "person3", ReferenceEmail = "*****@*****.**", SeatLabel = "A3"
                    },
                    new Seat {
                        Id = 4, PersonName = "person4", ReferenceEmail = "*****@*****.**", SeatLabel = "A1"
                    },
                }
            };

            appDbContext.Bookings.Add(booking1);


            appDbContext.SaveChanges();
            //detach everything
            foreach (var entity in appDbContext.ChangeTracker.Entries())
            {
                entity.State = EntityState.Detached;
            }
        }
Ejemplo n.º 8
0
 public Member FindFriendInMeetUp(MeetUp mU, Member m)
 {
     try
     {
         return(lsa.FindFriendInMeetUp(mU, m));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
 public void AddMeetup(MeetUp m)
 {
     try
     {
         lsa.AddMeetup(m);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Generate a customised meet up with the date, location, seats and cost specified.
        /// </summary>
        /// <returns>The meet up with specified values</returns>
        public MeetUp CreateNewMeetUp(DateTime meetUpDate, string meetUpLocation, int seatRows, int seatsPerRow, decimal costPerSeat)
        {
            MeetUp newMeetUp = new MeetUp()
            {
                CostPerSeat = costPerSeat,
                Location    = meetUpLocation,
                Date        = meetUpDate,
                SeatGrid    = GenerateSeatGrid(seatRows, seatsPerRow)
            };

            return(newMeetUp);
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit_my_meetup(MeetUp model)
        {
            MeetUp edit_meet = new MeetUp {
                Id_meetup        = model.Id_meetup, Name = model.Name, Type = model.Type, Description = model.Description, companyId_company = model.companyId_company,
                StartofSelection = model.StartofSelection, FinishofSelection = model.FinishofSelection, lng = model.lng, lat = model.lat, Adress = model.Adress, Cost = model.Cost
            };

            db.MeetUps.Update(edit_meet);
            await db.SaveChangesAsync();

            return(RedirectToAction("Profile", "Profile"));
        }
Ejemplo n.º 12
0
 public void AddMeetup(MeetUp m)
 {
     try
     {
         db.MeetUps.Add(m);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 13
0
        public void Set_Up_Default_Grid_With_100_Seats_For_New_MeetUp()
        {
            //Arrange
            IMeetUpManager manager = new MeetUpManager();

            //Act
            MeetUp meetUp = manager.CreateNewMeetUp();

            //Assert
            Assert.True(meetUp.SeatGrid != null);
            Assert.Equal(100, meetUp.SeatGrid.Seats.Count);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// generate a default meet up with the date as the last day of the month, 100 seats, and a default location
        /// </summary>
        /// <returns>The meet up with default values</returns>
        public MeetUp CreateNewMeetUp()
        {
            MeetUp newMeetUp = new MeetUp()
            {
                CostPerSeat = _costPerSeat,
                Location    = _meetUpLocation,
                Date        = GetLastWorkDateOfMonth(),
                SeatGrid    = GenerateSeatGrid(_seatRows, _seatPerRow)
            };

            return(newMeetUp);
        }
Ejemplo n.º 15
0
        public void Set_Up_Default_Grid_With_A1_J10_Labels()
        {
            //Arrange
            IMeetUpManager manager = new MeetUpManager();

            //Act
            MeetUp meetUp = manager.CreateNewMeetUp();

            //Assert
            Assert.Equal(100, meetUp.SeatGrid.Seats.Count);
            Assert.Equal("A1", meetUp.SeatGrid.Seats[0].SeatLabel);
            Assert.Equal("J10", meetUp.SeatGrid.Seats[99].SeatLabel);
        }
Ejemplo n.º 16
0
        //Creates a new meetup once the "make a switch" button is pressed
        private void CreateMeetUp(LunchBox friendLb, string information)
        {
            MeetUp mU = new MeetUp(information);

            controller.AddMeetup(mU);
            int meetUpId = mU.MeetUpId;

            MeetUp_Member mm  = new MeetUp_Member(member, mU);
            MeetUp_Member mm1 = new MeetUp_Member(friendLb.Member, mU);

            controller.AddMeetUp_Member(mm, meetUpId);
            controller.AddMeetUp_Member(mm1, meetUpId);
        }
Ejemplo n.º 17
0
 public void DeleteMeetup(long meetupId)
 {
     try
     {
         MeetUp m = FindMeetup(meetupId);
         db.MeetUps.Remove(m);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 18
0
        public void Set_Up_With_Defaults_For_New_MeetUp_By_Constructor()
        {
            //Arrange
            IMeetUpManager manager  = new MeetUpManager();
            DateTime       lastDate = new DateTime(2020, DateTime.Now.Month, DateTime.DaysInMonth(2020, DateTime.Now.Month));

            //Act
            MeetUp meetUp = manager.CreateNewMeetUp();

            //Assert
            Assert.Equal("The Offices, Somewhere", meetUp.Location);
            Assert.Equal(0M, meetUp.CostPerSeat);
            Assert.Equal(lastDate, meetUp.Date);
        }
 public MeetUp Update(MeetUp meetupToUpdate)
 {
     try
     {
         MeetUp meetUpFromUpdate = meetUps.Where(m => m.ID == meetupToUpdate.ID).FirstOrDefault();
         meetUpFromUpdate.MeetTime  = meetupToUpdate.MeetTime;
         meetUpFromUpdate.PlaceName = meetupToUpdate.PlaceName;
         meetUpFromUpdate.PlaceID   = meetupToUpdate.PlaceID;
         return(meetUpFromUpdate);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 20
0
        public void Set_Up_With_Constructor_Values_For_New_MeetUp()
        {
            //Arrange
            IMeetUpManager manager  = new MeetUpManager();
            DateTime       lastDate = DateTime.Now.AddDays(5);

            //Act
            MeetUp meetUp = manager.CreateNewMeetUp(lastDate, "London", 5, 5, 10);

            //Assert
            Assert.Equal("London", meetUp.Location);
            Assert.Equal(10M, meetUp.CostPerSeat);
            Assert.Equal(lastDate, meetUp.Date);
            Assert.Equal(25, meetUp.SeatGrid.Seats.Count);
        }
Ejemplo n.º 21
0
        public IActionResult DeleteActivity(int meetupId)
        {
            User current = GetUser();

            if (current == null)
            {
                return(Redirect("/"));
                //checking the ID
            }
            MeetUp remove = _context.Activities.FirstOrDefault(m => m.MeetUpId == meetupId);

            _context.Activities.Remove(remove);
            _context.SaveChanges();
            return(RedirectToAction("Home"));
        }
Ejemplo n.º 22
0
 //If a meet-up is doubled cliked on on the current member's profile, the member will be
 //redirected to the rating of the friend that the switch was made with
 private void dataGridViewMyMeetUpsMyAccount_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         MeetUp mU     = controller.FindMeetup(Convert.ToInt64(meetUpIdMyAccount));
         Member friend = controller.FindFriendInMeetUp(controller.FindMeetup(Convert.ToInt64(meetUpIdMyAccount)), member);
         textBoxSearchFriendFindPage.Text = friend.MemberId;
         buttonSearchForAFriendFindpage_Click(null, null);
         tabProgram.SelectedIndex = 0;
         comboBoxRateFriendFindpage.DroppedDown = true;
     }
     catch (Exception ex)
     {
         toolStripStatusLabelLunchSwitch.Text = ExceptionHandler.HandleExceptions(ex);
     }
 }
Ejemplo n.º 23
0
        public async Task <IActionResult> DeleteCompany(int?company_id)
        {
            Company delete = await db.Companies.FirstOrDefaultAsync(p => p.Id_company == company_id);

            MeetUp meetup = await db.MeetUps.FirstOrDefaultAsync(p => p.companyId_company == company_id);

            db.Companies.Remove(delete);
            await db.SaveChangesAsync();

            if (meetup != null)
            {
                db.MeetUps.Remove(meetup);
                await db.SaveChangesAsync();
            }
            return(RedirectToAction("Profile", "Profile"));
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> Delete(int?id, int?company_id)
        {
            int id_user = 0;
            var Profile = db.Users.Where(p => p.Email == @User.Identity.Name);

            foreach (User user in Profile)
            {
                id_user = user.Id;
            }
            MeetUp delete = await db.MeetUps.FirstOrDefaultAsync(p => p.Id_meetup == id && p.companyId_company == company_id);

            db.MeetUps.Remove(delete);
            await db.SaveChangesAsync();

            return(RedirectToAction("Profile", "Profile"));
        }
Ejemplo n.º 25
0
        public TodoController(TodoContext context)
        {
            _context = context;

            if (_context.Users.Count() == 0)
            {
                // Start read CSV files and add in DB
                using (var reader = new System.IO.StreamReader("./database/users.csv"))
                    using (var csv = new CsvReader(reader))
                    {
                        var records = csv.GetRecords <User>();
                        foreach (User user in records)
                        {
                            _context.Users.Add(user);
                            _context.SaveChanges();
                        }
                    }

                using (var reader = new System.IO.StreamReader("./database/meetup.csv"))
                    using (var csv = new CsvReader(reader))
                    {
                        var records = csv.GetRecords <MeetUp>();
                        foreach (MeetUp meetUp in records)
                        {
                            _context.MeetUps.Add(meetUp);
                            _context.SaveChanges();
                        }
                    }

                using (var reader = new System.IO.StreamReader("./database/meetupList.csv"))
                    using (var csv = new CsvReader(reader))
                    {
                        var records = csv.GetRecords <UserMeetUpsViewModel>();
                        foreach (UserMeetUpsViewModel meetUpItem in records)
                        {
                            User        user       = _context.Users.Find(meetUpItem.UserId);
                            MeetUp      meet       = _context.MeetUps.Find(meetUpItem.MeetUpId);
                            UserMeetUps userMeetUp = new UserMeetUps {
                                MeetUp = meet, User = user
                            };
                            _context.UserMeetUps.Add(userMeetUp);
                            _context.SaveChanges();
                        }
                    }
            }
        }
Ejemplo n.º 26
0
 public IActionResult Details(int meetUpId)
 {
     if (HttpContext.Session.GetInt32("UserId") == null)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.UserId = HttpContext.Session.GetInt32("UserId");
         // search database for wedding object with that weddingId
         // var wedding = dbContext.Weddings.FirstOrDefault(w => w.WeddingId == weddingId);
         // Adrien's
         MeetUp meetUp = dbContext.MeetUps.Include(m => m.Creator).Include(w => w.Reservations).ThenInclude(r => r.User).FirstOrDefault(w => w.MeetUpId == meetUpId);
         // ViewBag.User =dbContext.Users.FirstOrDefault( u => u.UserId == HttpContext.Session.GetInt32("UserId"));
         return(View("Details", meetUp));
     }
 }
Ejemplo n.º 27
0
        /// <summary
        /// This is main method for converting meetup data into RTM tasks
        /// </summary>
        /// <see href="https://www.newtonsoft.com/json">newtonsoft.com/json</see>
        /// <see href="https://www.meetup.com/meetup_api/docs/self/events/">Meetup Events API Documentation</see>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Click_Button(object sender, RoutedEventArgs e)
        {
            string rtmCon    = "RTM: Innitiate Connection...now...";
            string meetupCon = "MeetUp: Innitiate Connection...now...";

            ak = new AuthKeys
            {
                MyRTMkey          = iniConfigOfSecrets[2] ?? RTMkey.Text,
                MyRTMsecret       = iniConfigOfSecrets[3] ?? RTMsecret.Text,
                MyMeetupKey       = iniConfigOfSecrets[0] ?? MeetupKey.Text,
                MyMeetupKeySecret = iniConfigOfSecrets[1] ?? MeetupSecretKey.Text
            };

            meetup = new MeetUp(ak, RTM_Web_UI_Format.Text);
            rtm    = new RTM();

            // initiate RTM connection
            SetLoggingMessage_Other(rtmCon);
            rtm.InitiateConnection(ak);
            logger.Info("Done with RTM authKeys");

            // initiate Meetup connection
            SetLoggingMessage_Other(meetupCon);
            meetup.InitiateConnection();
            logger.Info("Done with MeetUp 'code' key");

            // open meetup dialog where you can insert code
            // https://stackoverflow.com/questions/2796470/wpf-create-a-dialog-prompt
            var myDia = new Dialog(ak);

            myDia.ShowDialog();
            Console.WriteLine("Meetup: so far correct! token: " + ak.MyMeetupCode);
            var JsOb = meetup.AuthorizeTokenAsync(ak.MyMeetupCode);

            logger.Info("Done with Meetup authKeys: " + JsOb.access_token);
            SetLoggingMessage_Other("Done with Meetup authKeys" + JsOb.access_token);

            string meetupDataURL   = meetup.CreateDataURL();
            var    meetupEventData = meetup.GetMeetupData(meetupDataURL);

            meetup.GetSampleData(meetupEventData);
            var rtmMeetupTasksData = meetup.Create_RTM_Tasks_From_Events(meetupEventData);
            var mu_event_venue     = meetup.PrepareMeetupTaskList_Venue_ToString(meetupEventData);

            rtm.SetRTMTasks(meetupEventData, rtmMeetupTasksData, mu_event_venue, checkbox_value);
        }
Ejemplo n.º 28
0
        public JsonResult Delete(int ID)
        {
            MeetUp deletedMeetup = new MeetUp();

            deletedMeetup = meetUpTable.GetAll().Where(m => m.ID == ID).FirstOrDefault();
            if (deletedMeetup != null)
            {
                meetUpTable.Delete(ID);
                Response.StatusCode = SetStatus("Deleted");
                IEnumerable <MeetUp> meetupsUpdated = meetUpTable.GetAll();
                return(Json(JsonConvert.SerializeObject(meetupsUpdated), JsonRequestBehavior.AllowGet));
            }
            else
            {
                Response.StatusCode = SetStatus(null);
                return(Json("{deleted: false}"));
            }
        }
Ejemplo n.º 29
0
 public IActionResult Destroy(int meetUpId)
 {
     if (HttpContext.Session.GetInt32("UserId") == null)
     {
         return(RedirectToAction("Logout"));
     }
     else
     {
         MeetUp removeMeetUp = dbContext.MeetUps.FirstOrDefault(w => w.MeetUpId == meetUpId);
         if (removeMeetUp == null)
         {
             return(RedirectToAction("Dashboard"));
         }
         dbContext.MeetUps.Remove(removeMeetUp);
         dbContext.SaveChanges();
         return(RedirectToAction("Dashboard"));
     }
 }
Ejemplo n.º 30
0
        public IActionResult CreateMovie(MeetUp newActivity)
        {
            User current = GetUser();

            if (current == null)
            {
                return(Redirect("/"));
                //checking the ID
            }
            if (ModelState.IsValid)
            {
                newActivity.UserId = current.UserId;
                //putting the id of the person logged in, into the id of the new movie being created
                _context.Activities.Add(newActivity);
                _context.SaveChanges();
                return(RedirectToAction("home"));
            }
            return(View("NewActivity"));
        }