Beispiel #1
0
 public ActivityController(
     IPrepOpsDataAccess prepOpsDataAccess,
     UserManager <ApplicationUser> userManager,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager       = userManager;
 }
 public ActivityController(
     IPrepOpsDataAccess prepOpsDataAccess,
     UserManager<ApplicationUser> userManager,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager = userManager;
 }
 public ActivityApiController(IPrepOpsDataAccess prepOpsDataAccess,
     UserManager<ApplicationUser> userManager,
     //GeoService geoService,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager = userManager;
     //_geoService = geoService;
     _closestLocations = closestLocations;
 }
Beispiel #4
0
 public ActivityApiController(IPrepOpsDataAccess prepOpsDataAccess,
                              UserManager <ApplicationUser> userManager,
                              //GeoService geoService,
                              IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager       = userManager;
     //_geoService = geoService;
     _closestLocations = closestLocations;
 }
Beispiel #5
0
 public static Tenant ToModel(this TenantViewModel tenant, IPrepOpsDataAccess dataAccess)
 {
     return new Tenant
     {
         Id = tenant.Id,
         Name = tenant.Name,
         Campaigns = tenant.Campaigns.ToModel(dataAccess).ToList(),
         LogoUrl = tenant.LogoUrl,
         WebUrl = tenant.WebUrl
     };
 }
Beispiel #6
0
 public static Tenant ToModel(this TenantViewModel tenant, IPrepOpsDataAccess dataAccess)
 {
     return(new Tenant
     {
         Id = tenant.Id,
         Name = tenant.Name,
         Campaigns = tenant.Campaigns.ToModel(dataAccess).ToList(),
         LogoUrl = tenant.LogoUrl,
         WebUrl = tenant.WebUrl
     });
 }
Beispiel #7
0
        /// <summary>
        /// Returns null when there is no matching campaign for the campaign Id.
        /// </summary>
        public static Activity ToModel(this ActivityViewModel activity, IPrepOpsDataAccess dataAccess)
        {
            var campaign = dataAccess.GetCampaign(activity.CampaignId);

            if (campaign == null)
            {
                return(null);
            }

            Activity newActivity = new Activity()
            {
                Id               = activity.Id,
                Campaign         = campaign,
                EndDateTimeUtc   = activity.EndDateTime.UtcDateTime,
                StartDateTimeUtc = activity.StartDateTime.UtcDateTime,
                Location         = new Location()
                {
                    Address1   = activity.Location.Address1,
                    Address2   = activity.Location.Address2,
                    City       = activity.Location.City,
                    Country    = "US",
                    PostalCode = activity.Location.PostalCode,
                    State      = activity.Location.State
                },
                Name = activity.Title
            };
            var tasks = new List <PrepOpsTask>();

            foreach (TaskViewModel tvm in activity.Tasks)
            {
                tasks.Add(new PrepOpsTask()
                {
                    Activity    = newActivity,
                    Name        = tvm.Name,
                    Id          = tvm.Id,
                    Description = tvm.Description
                });
            }
            newActivity.Tasks = tasks;
            return(newActivity);
        }
Beispiel #8
0
        public static Campaign ToModel(this CampaignViewModel campaign, IPrepOpsDataAccess dataAccess)
        {
            var tenant = dataAccess.GetTenant(campaign.ManagingTenantId);

            if (tenant == null)
            {
                return(null);
            }

            return(new Campaign
            {
                Id = campaign.Id,
                Description = campaign.Description,
                Name = campaign.Name,
                ManagingTenant = tenant,
                ParticipatingTenants = campaign.ParticipatingTenants,
                Activities = campaign.Activities.ToModel(dataAccess).ToList(),
                EndDateTimeUtc = campaign.EndDate.UtcDateTime,
                StartDateTimeUtc = campaign.StartDate.UtcDateTime
            });
        }
Beispiel #9
0
        public static PrepOpsTask ToModel(this TaskViewModel task, IPrepOpsDataAccess dataAccess)
        {
            var activity = dataAccess.GetActivity(task.ActivityId);

            if (activity == null)
            {
                return(null);
            }

            bool        newTask = true;
            PrepOpsTask dbtask;

            if (task.Id == 0)
            {
                dbtask = new PrepOpsTask();
            }
            else
            {
                dbtask  = dataAccess.GetTask(task.Id);
                newTask = false;
            }

            // dbtask.Id = task.Id;
            dbtask.Description      = task.Description;
            dbtask.Activity         = activity;
            dbtask.EndDateTimeUtc   = task.EndDateTime.HasValue ? task.EndDateTime.Value.UtcDateTime : new Nullable <DateTime>();
            dbtask.StartDateTimeUtc = task.EndDateTime.HasValue ? task.StartDateTime.Value.UtcDateTime : new Nullable <DateTime>();
            dbtask.Name             = task.Name;

            // Workaround:  POST is bringing in empty AssignedVolunteers.  Clean this up. Discussing w/ Kiran Challa.
            // Workaround: the if statement is superflous, and should go away once we have the proper fix referenced above.
            if (task.AssignedVolunteers != null)
            {
                var bogusAssignedVolunteers = (from assignedVolunteer in task.AssignedVolunteers
                                               where string.IsNullOrEmpty(assignedVolunteer.UserId)
                                               select assignedVolunteer).ToList();
                foreach (var bogus in bogusAssignedVolunteers)
                {
                    task.AssignedVolunteers.Remove(bogus);
                }
            }
            // end workaround


            if (task.AssignedVolunteers != null && task.AssignedVolunteers.Count > 0)
            {
                var taskUsersList = task.AssignedVolunteers.Select(tvm => new TaskUsers
                {
                    Task = dbtask,
                    User = dataAccess.GetUser(tvm.UserId)
                }).ToList();

                // We may be updating an existing task
                if (newTask || dbtask.AssignedVolunteers.Count == 0)
                {
                    dbtask.AssignedVolunteers = taskUsersList;
                }
                else
                {
                    // Can probably rewrite this more efficiently.
                    foreach (TaskUsers taskUsers in taskUsersList)
                    {
                        if (!(from entry in dbtask.AssignedVolunteers
                              where entry.User.Id == taskUsers.User.Id
                              select entry).Any())
                        {
                            dbtask.AssignedVolunteers.Add(taskUsers);
                        }
                    }
                }
            }

            return(dbtask);
        }
Beispiel #10
0
        public static Campaign ToModel(this CampaignViewModel campaign, IPrepOpsDataAccess dataAccess)
        {
            var tenant = dataAccess.GetTenant(campaign.ManagingTenantId);

            if (tenant == null)
                return null;

            return new Campaign
            {
                Id = campaign.Id,
                Description = campaign.Description,
                Name = campaign.Name,
                ManagingTenant = tenant,
                ParticipatingTenants = campaign.ParticipatingTenants,
                Activities = campaign.Activities.ToModel(dataAccess).ToList(),
                EndDateTimeUtc = campaign.EndDate.UtcDateTime,
                StartDateTimeUtc = campaign.StartDate.UtcDateTime
            };
        }
Beispiel #11
0
 public static IEnumerable<Campaign> ToModel(this IEnumerable<CampaignViewModel> campaigns, IPrepOpsDataAccess dataAccess)
 {
     return campaigns.Select(campaign => campaign.ToModel(dataAccess));
 }
 public TenantController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Beispiel #13
0
 public TaskApiController(IPrepOpsDataAccess prepOpsDataAccess, UserManager<ApplicationUser> userManager)
 {
     _userManager = userManager;
     _prepOpsDataAccess = prepOpsDataAccess;
 }
Beispiel #14
0
 public static IEnumerable<Activity> ToModel(this IEnumerable<ActivityViewModel> activities, IPrepOpsDataAccess dataAccess)
 {
     return activities.Select(activity => activity.ToModel(dataAccess));
 }
Beispiel #15
0
 public static IEnumerable<PrepOpsTask> ToModel(this IEnumerable<TaskViewModel> tasks, IPrepOpsDataAccess dataContext)
 {
     return tasks.Select(task => task.ToModel(dataContext));
 }
Beispiel #16
0
 public static IEnumerable <PrepOpsTask> ToModel(this IEnumerable <TaskViewModel> tasks, IPrepOpsDataAccess dataContext)
 {
     return(tasks.Select(task => task.ToModel(dataContext)));
 }
 public TenantController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Beispiel #18
0
 public ActivityController(IPrepOpsDataAccess dataAccess, UserManager <ApplicationUser> userManager, IImageService imageService)
 {
     _dataAccess   = dataAccess;
     _userManager  = userManager;
     _imageService = imageService;
 }
Beispiel #19
0
 public TaskApiController(IPrepOpsDataAccess prepOpsDataAccess, UserManager <ApplicationUser> userManager)
 {
     _userManager       = userManager;
     _prepOpsDataAccess = prepOpsDataAccess;
 }
 public CampaignController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Beispiel #21
0
 public static IEnumerable<Tenant> ToModel(this IEnumerable<TenantViewModel> tenants, IPrepOpsDataAccess dataAccess)
 {
     return tenants.Select(x => x.ToModel(dataAccess));
 }
Beispiel #22
0
 public static IEnumerable <Campaign> ToModel(this IEnumerable <CampaignViewModel> campaigns, IPrepOpsDataAccess dataAccess)
 {
     return(campaigns.Select(campaign => campaign.ToModel(dataAccess)));
 }
Beispiel #23
0
 public static IEnumerable <Tenant> ToModel(this IEnumerable <TenantViewModel> tenants, IPrepOpsDataAccess dataAccess)
 {
     return(tenants.Select(x => x.ToModel(dataAccess)));
 }
Beispiel #24
0
        public static PrepOpsTask ToModel(this TaskViewModel task, IPrepOpsDataAccess dataAccess)
        {
            var activity = dataAccess.GetActivity(task.ActivityId);

            if (activity == null)
                return null;

            bool newTask = true;
            PrepOpsTask dbtask;

            if (task.Id == 0)
            {
                dbtask = new PrepOpsTask();
            }
            else
            {
                dbtask = dataAccess.GetTask(task.Id);
                newTask = false;
            }

            // dbtask.Id = task.Id;
            dbtask.Description = task.Description;
            dbtask.Activity = activity;
            dbtask.EndDateTimeUtc = task.EndDateTime.HasValue ? task.EndDateTime.Value.UtcDateTime : new Nullable<DateTime>();
            dbtask.StartDateTimeUtc = task.EndDateTime.HasValue ? task.StartDateTime.Value.UtcDateTime : new Nullable<DateTime>();
            dbtask.Name = task.Name;

            // Workaround:  POST is bringing in empty AssignedVolunteers.  Clean this up. Discussing w/ Kiran Challa.
            // Workaround: the if statement is superflous, and should go away once we have the proper fix referenced above.
            if (task.AssignedVolunteers != null)
            {
                var bogusAssignedVolunteers = (from assignedVolunteer in task.AssignedVolunteers
                                               where string.IsNullOrEmpty(assignedVolunteer.UserId)
                                               select assignedVolunteer).ToList();
                foreach (var bogus in bogusAssignedVolunteers)
                {
                    task.AssignedVolunteers.Remove(bogus);
                }
            }
            // end workaround

            if (task.AssignedVolunteers != null && task.AssignedVolunteers.Count > 0)
            {
                var taskUsersList = task.AssignedVolunteers.Select(tvm => new TaskUsers
                {
                    Task = dbtask,
                    User = dataAccess.GetUser(tvm.UserId)
                }).ToList();

                // We may be updating an existing task
                if (newTask || dbtask.AssignedVolunteers.Count == 0)
                {
                    dbtask.AssignedVolunteers = taskUsersList;
                }
                else
                {
                    // Can probably rewrite this more efficiently.
                    foreach (TaskUsers taskUsers in taskUsersList)
                    {
                        if (!(from entry in dbtask.AssignedVolunteers
                              where entry.User.Id == taskUsers.User.Id
                              select entry).Any())
                        {
                            dbtask.AssignedVolunteers.Add(taskUsers);
                        }
                    }
                }
            }

            return dbtask;
        }
Beispiel #25
0
        /// <summary>
        /// Returns null when there is no matching campaign for the campaign Id.
        /// </summary>
        public static Activity ToModel(this ActivityViewModel activity, IPrepOpsDataAccess dataAccess)
        {
            var campaign = dataAccess.GetCampaign(activity.CampaignId);

            if (campaign == null)
                return null;

            Activity newActivity = new Activity()
            {
                Id = activity.Id,
                Campaign = campaign,
                EndDateTimeUtc = activity.EndDateTime.UtcDateTime,
                StartDateTimeUtc = activity.StartDateTime.UtcDateTime,
                Location = new Location()
                {
                    Address1 = activity.Location.Address1,
                    Address2 = activity.Location.Address2,
                    City = activity.Location.City,
                    Country = "US",
                    PostalCode = activity.Location.PostalCode,
                    State = activity.Location.State
                },
                Name = activity.Title
            };
            var tasks = new List<PrepOpsTask>();
            foreach (TaskViewModel tvm in activity.Tasks)
            {
                tasks.Add(new PrepOpsTask()
                {
                    Activity = newActivity,
                    Name = tvm.Name,
                    Id = tvm.Id,
                    Description = tvm.Description
                });
            }
            newActivity.Tasks = tasks;
            return newActivity;
        }
Beispiel #26
0
 public TaskController(IPrepOpsDataAccess dataAccess, UserManager<ApplicationUser> usermanager)
 {
     _dataAccess = dataAccess;
     _userManager = usermanager;
 }
Beispiel #27
0
 public static IEnumerable <Activity> ToModel(this IEnumerable <ActivityViewModel> activities, IPrepOpsDataAccess dataAccess)
 {
     return(activities.Select(activity => activity.ToModel(dataAccess)));
 }
 public ActivityController(IPrepOpsDataAccess dataAccess, UserManager<ApplicationUser> userManager, IImageService imageService)
 {
     _dataAccess = dataAccess;
     _userManager = userManager;
     _imageService = imageService;
 }
 public CampaignController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }