Exemple #1
0
        private FulfillableTransactionItem GetFulfillableTransactionItem(long fulfillableItemId)
        {
            // Load the fulfillable.
            //
            if (m_fulfillable == null)
            {
                m_fulfillable = m_ctx.Fulfillables.Where(r => r.FulfillableItems.Any(r => r.FulfillableItemId == fulfillableItemId)).Include(r => r.FulfillableItems).First();
            }

            // Find the specified fulfillable item.
            //
            var dbFulfillableItem = m_fulfillable.FulfillableItems.Where(r => r.FulfillableItemId == fulfillableItemId).First();

            // Retrieve or create a corresponding transaction item for the fulfillable item.
            //
            var dbFulfillableTransactionItem = m_fulfillableTransaction.FulfillableTransactionItems.Where(r => r.FulfillableItemId == fulfillableItemId).SingleOrDefault();

            if (dbFulfillableTransactionItem == null)
            {
                dbFulfillableTransactionItem = new FulfillableTransactionItem()
                {
                    FulfillableTransaction = m_fulfillableTransaction,
                    FulfillableItem        = dbFulfillableItem,
                    RequestQuantity        = 0,
                    ReturnQuantity         = 0,
                    CompleteQuantity       = 0
                };
                m_fulfillableTransaction.FulfillableTransactionItems.Add(dbFulfillableTransactionItem);
            }

            return(dbFulfillableTransactionItem);
        }
Exemple #2
0
        public IActionResult Success(Fulfillable fulfillable, RequestHelpFormVariant requestHelpFormVariant, string referringGroup, string source)
        {
            source = ValidateSource(source);

            string button;

            string message = requestHelpFormVariant switch
            {
                RequestHelpFormVariant.FtLOS => @"<p>Your request has been received and we are looking for a volunteer who can help. Someone should get in touch shortly.</p>
                                                    <p>For the Love of Scrubs ask for a small donation of £3 - £4 per face covering to cover the cost of materials and help support their communities. Without donations they aren’t able to continue their good work.</p>
                                                    <p>If you are able to donate, you can do so on their Go Fund Me page <a href='https://www.gofundme.com/f/for-the-love-of-scrubs-face-coverings\' target=\'_blank\'>here</a>.<p>",
                RequestHelpFormVariant.Ruddington => @"<p>Your request has been received and we're looking for a volunteer who can help, as soon as we find someone we’ll let you know by email. Please be aware that we cannot guarantee help, but we’ll do our best to find a volunteer near you.</p>",
                _ => @"<p>Your request has been received and we are looking for a volunteer who can help. Someone should get in touch shortly.</p>"
            };

            if (User.Identity.IsAuthenticated)
            {
                button = $"<a href='/account' class='btn cta large fill mt16 cta--orange'>Done</a>";
            }
            else
            {
                message += "<p><strong>Would you be happy to help a neighbour?</strong></p>";
                message += "<p>Could you help a member of your local community if they needed something? There are lots of different ways you can help, from offering a friendly chat, to picking up groceries or prescriptions, or even sewing a face covering. Please take 5 minutes to sign up now.</p>";
                button   = $"<a href='/login' class='btn cta large fill mt16 '>Sign Up or Log In</a>";
            }

            List <NotificationModel> notifications = new List <NotificationModel> {
                new NotificationModel
                {
                    Title    = "Thank you",
                    Subtitle = "Your request has been received",
                    Type     = Enums.Account.NotificationType.Success,
                    Message  = message,
                    Button   = button
                }
            };

            SuccessViewModel vm = new SuccessViewModel
            {
                Notifications = notifications,
                RequestLink   = $"/request-help/{referringGroup}/{source}"
            };

            return(View(vm));
        }
Exemple #3
0
        public async Task WhenAccessRestrictedByRole_ReturnsCorrectResponse(int createdByUserId, GroupRoles role, Fulfillable fulfillable, int timesGroupMemberCalled)
        {
            requestId      = 1;
            _validPostcode = true;
            _emailSent     = true;
            int referringGroupId = -20;

            Guid guid    = Guid.NewGuid();
            var  request = new PostNewRequestForHelpRequest
            {
                HelpRequest = new HelpRequest
                {
                    RequestorType = RequestorType.Myself,
                    Recipient     = new RequestPersonalDetails
                    {
                        Address = new Address
                        {
                            Postcode = "test",
                        }
                    },
                    VolunteerUserId  = 1,
                    CreatedByUserId  = createdByUserId,
                    ReferringGroupId = referringGroupId
                },
                NewJobsRequest = new NewJobsRequest
                {
                    Jobs = new List <Job>
                    {
                        new Job
                        {
                            Guid            = guid,
                            HealthCritical  = true,
                            DueDays         = 5,
                            SupportActivity = SupportActivities.Shopping
                        }
                    }
                }
            };

            _formVariantResponse = new GetRequestHelpFormVariantResponse()
            {
                AccessRestrictedByRole   = true,
                RequestorDefinedByGroup  = true,
                RequestHelpFormVariant   = RequestHelpFormVariant.Default,
                TargetGroups             = TargetGroups.GenericGroup,
                RequestorPersonalDetails = new RequestPersonalDetails()
                {
                    FirstName    = "First",
                    LastName     = "Last",
                    EmailAddress = "Email",
                    MobileNumber = "Mobile",
                    OtherNumber  = "Other"
                },
                SuppressRecipientPersonalDetails = true
            };

            _getGroupMemberResponse = new GetGroupMemberResponse()
            {
                UserInGroup = new UserInGroup()
                {
                    UserId     = 1,
                    GroupId    = 1,
                    GroupRoles = new List <GroupRoles>()
                    {
                        role
                    }
                }
            };

            _getGroupResponse = new GetGroupResponse()
            {
                Group = new Group()
                {
                    GroupId = referringGroupId
                }
            };

            _getUserRolesResponse = new GetUserRolesResponse()
            {
                UserGroupRoles = new Dictionary <int, List <int> >()
            };

            _getNewRequestActionsResponse = new GetNewRequestActionsResponse()
            {
                Actions = new Dictionary <Guid, TaskAction>(), RequestTaskActions = new Dictionary <NewTaskAction, List <int> >()
            };
            _getNewRequestActionsResponse.Actions.Add(guid, new TaskAction()
            {
                TaskActions = new Dictionary <NewTaskAction, List <int> >()
            });
            _getNewRequestActionsResponse.Actions[guid].TaskActions.Add(NewTaskAction.AssignToVolunteer, new List <int>()
            {
                1
            });

            var response = await _classUnderTest.Handle(request, new CancellationToken());

            _groupService.Verify(x => x.GetRequestHelpFormVariant(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Once);
            _groupService.Verify(x => x.GetGroupMember(It.IsAny <GetGroupMemberRequest>()), Times.Exactly(timesGroupMemberCalled));
            Assert.AreEqual(fulfillable, response.Fulfillable);
        }