public void SetTaskIdAndTaskName_WhenTaskSignupsTaskIsNotNull()
 {
     var taskSignup = new TaskSignup { Task = new AllReadyTask { Id = 1, Name = "TaskName" } };
     var sut = new TaskSignupViewModel(taskSignup);
     Assert.Equal(sut.TaskId, taskSignup.Task.Id);
     Assert.Equal(sut.TaskName, taskSignup.Task.Name);
 }
 public void SetUserIdAndUserName_WhenTaskSignupsUserIsNotNull()
 {
     var taskSignup = new TaskSignup { User = new ApplicationUser { Id = "1", UserName = "******"} };
     var sut = new TaskSignupViewModel(taskSignup);
     Assert.Equal(sut.UserId, taskSignup.User.Id);
     Assert.Equal(sut.UserName, taskSignup.User.UserName);
 }
        protected override void LoadTestData()
        {
            var htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };

            var queenAnne = new Event()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
            };

            var username1 = $"*****@*****.**";
            var username2 = $"*****@*****.**";

            var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
            Context.Users.Add(user1);
            var user2 = new ApplicationUser { UserName = username2, Email = username2, EmailConfirmed = true };
            Context.Users.Add(user2);

            var task = new AllReadyTask
            {
                Id = 1,
                Name = "Task 1",
                Event = queenAnne,
            };

            var taskSignup = new TaskSignup
            {
                Id = 1,
                User = user1,
                Task = task
            };

            htb.Campaigns.Add(firePrev);            
            Context.Organizations.Add(htb);
            Context.Events.Add(queenAnne);
            Context.Tasks.Add(task);
            Context.TaskSignups.Add(taskSignup);

            Context.SaveChanges();
        }
        public TasksByApplicationUserIdQueryHandlerShould()
        {
            message = new TasksByApplicationUserIdQuery { ApplicationUserId = Guid.NewGuid().ToString() };
            alreadyTask = new AllReadyTask { Name = "name" };
            task = new TaskSignup { User = new ApplicationUser { Id = message.ApplicationUserId }, Task = alreadyTask };

            Context.Add(alreadyTask);
            Context.Add(task);
            Context.SaveChanges();

            sut = new TasksByApplicationUserIdQueryHandler(Context);
        }
        protected override void LoadTestData()
        {
            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);

            var queenAnne = new Event
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
                EventType = EventType.Itinerary
            };

            var itinerary = new Itinerary
            {
                Event = queenAnne,
                Name = "1st Itinerary",
                Id = 1,
                Date = new DateTime(2016, 07, 01)
            };

            var taskSignUp = new TaskSignup { Id = 1, ItineraryId = 2, TaskId = 1 };

            Context.Organizations.Add(htb);
            Context.Campaigns.Add(firePrev);
            Context.Events.Add(queenAnne);
            Context.Itineraries.Add(itinerary);
            Context.TaskSignups.Add(taskSignUp);

            Context.SaveChanges();
        }
        public TaskSignupViewModel(TaskSignup taskSignup)
        {
            Id = taskSignup.Id;
            Status = taskSignup.Status;
            StatusDateTimeUtc = taskSignup.StatusDateTimeUtc;
            StatusDescription = taskSignup.StatusDescription;

            if (taskSignup.Task != null)
            {
                TaskId = taskSignup.Task.Id;
                TaskName = taskSignup.Task.Name;
            }

            if (taskSignup.User != null)
            {
                UserId = taskSignup.User.Id;
                UserName = taskSignup.User.UserName;
            }
        }
        protected override void LoadTestData()
        {
            _user = new ApplicationUser
            {
                PhoneNumber = "123",
                Email = "*****@*****.**"
            };

            _taskSignup = new TaskSignup
            {
                Id = 1,
                PreferredEmail = "*****@*****.**",
                PreferredPhoneNumber = "456",
                User = _user
            };

            _taskSignupNoContactPreferences = new TaskSignup
            {
                Id = 2,
                User = _user
            };

            _taskSignupNoContacts = new TaskSignup
            {
                Id = 3,
                User = new ApplicationUser()
            };

            _itinerary = new Itinerary
            {
                Id = 1,
                Date = _itineraryDate = new DateTime(2016, 1, 1, 10, 30, 0)
            };

            Context.Users.Add(_user);
            Context.TaskSignups.Add(_taskSignup);
            Context.TaskSignups.Add(_taskSignupNoContactPreferences);
            Context.TaskSignups.Add(_taskSignupNoContacts);
            Context.Itineraries.Add(_itinerary);
            Context.SaveChanges();
        }
Beispiel #8
0
 Task IAllReadyDataAccess.UpdateTaskSignupAsync(TaskSignup value)
 {
     _dbContext.TaskSignups.Update(value);
     return(_dbContext.SaveChangesAsync());
 }
 Task IAllReadyDataAccess.AddTaskSignupAsync(TaskSignup taskSignup)
 {
     _dbContext.TaskSignups.Add(taskSignup);
     return(_dbContext.SaveChangesAsync());
 }
        protected override void LoadTestData()
        {
            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);

            var queenAnne = new Event
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
                EventType = EventType.Itinerary
            };

            var itinerary = new Itinerary
            {
                Event = queenAnne,
                Name = "1st Itinerary",
                Id = 1,
                Date = new DateTime(2016, 07, 01)
            };

            var task = new AllReadyTask
            {
                Id = 1,
                Event = queenAnne,
                Name = "A Task",
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 7, 4, 18, 0, 0).ToUniversalTime()
            };

            var user = new ApplicationUser
            {
                Id = Guid.NewGuid().ToString(),
                Email = "*****@*****.**"
            };

            var taskSignup = new TaskSignup
            {
                Id = 1,
                User = user,
                Task = task,
                Itinerary = itinerary
            };

            var request = new Request
            {
                RequestId = Guid.NewGuid(),
                Name = "Request 1",
                Address = "Street Name 1",
                City = "Seattle"
            };

            var itineraryReq = new ItineraryRequest
            {
                Request = request,
                Itinerary = itinerary
            };
            
            Context.Organizations.Add(htb);
            Context.Campaigns.Add(firePrev);
            Context.Events.Add(queenAnne);
            Context.Itineraries.Add(itinerary);
            Context.Tasks.Add(task);
            Context.Users.Add(user);
            Context.Requests.Add(request);
            Context.ItineraryRequests.Add(itineraryReq);
            Context.TaskSignups.Add(taskSignup);
            Context.SaveChanges();
        }
        protected override void LoadTestData()
        {
            var seattlePostalCode = "98117";
            var seattle = new Location
            {
                Address1 = "123 Main Street",
                Address2 = "Unit 2",
                City = "Seattle",
                PostalCode = seattlePostalCode,
                Country = "USA",
                State = "WA",
                Name = "Organizer name",
                PhoneNumber = "555-555-5555"
            };

            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);

            var queenAnne = new Event
            {
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = seattle,
                RequiredSkills = new List<EventSkill>(),
                EventType = EventType.Itinerary
            };

            var rallyEvent = new Event
            {
                Name = "Queen Anne Fire Prevention Day Rally",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = seattle,
                RequiredSkills = new List<EventSkill>(),
                EventType = EventType.Rally
            };

            var task1 = new AllReadyTask
            {
                Event = rallyEvent,
                Name = "Task1",
                IsLimitVolunteers = false,
                StartDateTime = new DateTime(2016, 7, 5, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2016, 7, 5, 15, 0, 0).ToUniversalTime()
            };

            var request1 = new Request
            {
                RequestId = Guid.NewGuid(),
                Name = "Request1",
                Status = RequestStatus.Assigned,
                Latitude = 50.768,
                Longitude = 0.2905
            };

            var request2 = new Request
            {
                RequestId = Guid.NewGuid(),
                Name = "Request2",
                Status = RequestStatus.Assigned,
                Latitude = 50.768,
                Longitude = 0.2905
            };

            var request3 = new Request
            {
                RequestId = Guid.NewGuid(),
                Name = "Request3",
                Status = RequestStatus.Assigned,
                Latitude = 50.768,
                Longitude = 0.2905
            };

            var itinerary1 = new Itinerary
            {
                Date = new DateTime(2015, 07, 5),
                Name = "Itinerary1",
                Event = queenAnne
            };

            var itinerary2 = new Itinerary
            {
                Date = new DateTime(2016, 08, 01),
                Name = "Itinerary2",
                Event = queenAnne
            };

            var itineraryReq1 = new ItineraryRequest
            {
                RequestId = request1.RequestId,
                Itinerary = itinerary1
            };

            var itineraryReq2 = new ItineraryRequest
            {
                RequestId = request2.RequestId,
                Itinerary = itinerary1
            };

            var itineraryReq3 = new ItineraryRequest
            {
                RequestId = request3.RequestId,
                Itinerary = itinerary2
            };

            var user1 = new ApplicationUser
            {
                Id = Guid.NewGuid().ToString(),
                UserName = "******"
            };

            var taskSignup = new TaskSignup
            {
                Itinerary = itinerary1,
                Task = task1,
            };
            Context.Locations.Add(seattle);
            Context.Requests.AddRange(request1, request2, request3);
            Context.Itineraries.AddRange(itinerary1, itinerary2);
            Context.ItineraryRequests.AddRange(itineraryReq1, itineraryReq2, itineraryReq3);
            Context.Organizations.Add(htb);
            Context.Events.Add(queenAnne);
            Context.Events.Add(rallyEvent);
            Context.Users.Add(user1);
            Context.Tasks.Add(task1);
            Context.TaskSignups.Add(taskSignup);

            Context.SaveChanges();
        }
 Task IAllReadyDataAccess.UpdateTaskSignupAsync(TaskSignup value)
 {
     _dbContext.TaskSignups.Update(value);
     return _dbContext.SaveChangesAsync();
 }
 Task IAllReadyDataAccess.AddTaskSignupAsync(TaskSignup taskSignup)
 {
     _dbContext.TaskSignups.Add(taskSignup);
     return _dbContext.SaveChangesAsync();
 }
        public EventDetailQueryHandlerShould()
        {
            var org = new Organization
            {
                Id = 1,
                Name = "Organization"
            };

            var campaign = new Campaign
            {
                Id = 1,
                Name = "Campaign",
                ManagingOrganization = org
            };

            var campaignEvent = new Models.Event
            {
                Id = 1,
                Name = "Event",
                Campaign = campaign
            };

            var task1 = new AllReadyTask
            {
                Id = 1,
                Name = "Task 1",
                Event = campaignEvent,
                NumberOfVolunteersRequired = 22
            };

            var task2 = new AllReadyTask
            {
                Id = 2,
                Name = "Task 2",
                Event = campaignEvent,
                NumberOfVolunteersRequired = 8
            };

            var user = new ApplicationUser { Id = Guid.NewGuid().ToString(), Email = "[email protected] " };
            var user2 = new ApplicationUser { Id = Guid.NewGuid().ToString(), Email = "[email protected] " };

            var taskSignup1 = new TaskSignup
            {
                User = user,
                Task = task1,
                Status = TaskStatus.Accepted.ToString()
            };

            var taskSignup2 = new TaskSignup
            {
                User = user2,
                Task = task1,
                Status = TaskStatus.Accepted.ToString()
            };

            var taskSignup3 = new TaskSignup
            {
                User = user,
                Task = task2,
                Status = TaskStatus.Accepted.ToString()
            };

            Context.Add(campaign);
            Context.Add(campaignEvent);
            Context.Add(task1);
            Context.Add(task2);
            Context.Add(user);
            Context.Add(user2);
            Context.Add(taskSignup1);
            Context.Add(taskSignup2);
            Context.Add(taskSignup3);
            Context.SaveChanges();
        }