Exemplo n.º 1
0
 public ActivityController(
     IPrepOpsDataAccess prepOpsDataAccess,
     UserManager <ApplicationUser> userManager,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager       = userManager;
 }
Exemplo n.º 2
0
 public ActivityController(
     IPrepOpsDataAccess prepOpsDataAccess,
     UserManager<ApplicationUser> userManager,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager = userManager;
 }
Exemplo n.º 3
0
 public ActivityApiController(IPrepOpsDataAccess prepOpsDataAccess,
     UserManager<ApplicationUser> userManager,
     //GeoService geoService,
     IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager = userManager;
     //_geoService = geoService;
     _closestLocations = closestLocations;
 }
Exemplo n.º 4
0
 public ActivityApiController(IPrepOpsDataAccess prepOpsDataAccess,
                              UserManager <ApplicationUser> userManager,
                              //GeoService geoService,
                              IClosestLocations closestLocations)
 {
     _prepOpsDataAccess = prepOpsDataAccess;
     _userManager       = userManager;
     //_geoService = geoService;
     _closestLocations = closestLocations;
 }
Exemplo n.º 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
     };
 }
Exemplo n.º 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
     });
 }
Exemplo n.º 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);
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 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);
        }
Exemplo n.º 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
            };
        }
Exemplo n.º 11
0
 public static IEnumerable<Campaign> ToModel(this IEnumerable<CampaignViewModel> campaigns, IPrepOpsDataAccess dataAccess)
 {
     return campaigns.Select(campaign => campaign.ToModel(dataAccess));
 }
Exemplo n.º 12
0
 public TenantController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Exemplo n.º 13
0
 public TaskApiController(IPrepOpsDataAccess prepOpsDataAccess, UserManager<ApplicationUser> userManager)
 {
     _userManager = userManager;
     _prepOpsDataAccess = prepOpsDataAccess;
 }
Exemplo n.º 14
0
 public static IEnumerable<Activity> ToModel(this IEnumerable<ActivityViewModel> activities, IPrepOpsDataAccess dataAccess)
 {
     return activities.Select(activity => activity.ToModel(dataAccess));
 }
Exemplo n.º 15
0
 public static IEnumerable<PrepOpsTask> ToModel(this IEnumerable<TaskViewModel> tasks, IPrepOpsDataAccess dataContext)
 {
     return tasks.Select(task => task.ToModel(dataContext));
 }
Exemplo n.º 16
0
 public static IEnumerable <PrepOpsTask> ToModel(this IEnumerable <TaskViewModel> tasks, IPrepOpsDataAccess dataContext)
 {
     return(tasks.Select(task => task.ToModel(dataContext)));
 }
Exemplo n.º 17
0
 public TenantController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Exemplo n.º 18
0
 public ActivityController(IPrepOpsDataAccess dataAccess, UserManager <ApplicationUser> userManager, IImageService imageService)
 {
     _dataAccess   = dataAccess;
     _userManager  = userManager;
     _imageService = imageService;
 }
Exemplo n.º 19
0
 public TaskApiController(IPrepOpsDataAccess prepOpsDataAccess, UserManager <ApplicationUser> userManager)
 {
     _userManager       = userManager;
     _prepOpsDataAccess = prepOpsDataAccess;
 }
Exemplo n.º 20
0
 public CampaignController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Exemplo n.º 21
0
 public static IEnumerable<Tenant> ToModel(this IEnumerable<TenantViewModel> tenants, IPrepOpsDataAccess dataAccess)
 {
     return tenants.Select(x => x.ToModel(dataAccess));
 }
Exemplo n.º 22
0
 public static IEnumerable <Campaign> ToModel(this IEnumerable <CampaignViewModel> campaigns, IPrepOpsDataAccess dataAccess)
 {
     return(campaigns.Select(campaign => campaign.ToModel(dataAccess)));
 }
Exemplo n.º 23
0
 public static IEnumerable <Tenant> ToModel(this IEnumerable <TenantViewModel> tenants, IPrepOpsDataAccess dataAccess)
 {
     return(tenants.Select(x => x.ToModel(dataAccess)));
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 26
0
 public TaskController(IPrepOpsDataAccess dataAccess, UserManager<ApplicationUser> usermanager)
 {
     _dataAccess = dataAccess;
     _userManager = usermanager;
 }
Exemplo n.º 27
0
 public static IEnumerable <Activity> ToModel(this IEnumerable <ActivityViewModel> activities, IPrepOpsDataAccess dataAccess)
 {
     return(activities.Select(activity => activity.ToModel(dataAccess)));
 }
Exemplo n.º 28
0
 public ActivityController(IPrepOpsDataAccess dataAccess, UserManager<ApplicationUser> userManager, IImageService imageService)
 {
     _dataAccess = dataAccess;
     _userManager = userManager;
     _imageService = imageService;
 }
Exemplo n.º 29
0
 public CampaignController(IPrepOpsDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }