Example #1
0
 public IHttpActionResult Get()
 {
     return(Authorized(token =>
     {
         var contactId = _authenticationService.GetContactId(token);
         return (Ok(_subscriptionService.GetSubscriptions(contactId, token)));
     }));
 }
 public IHttpActionResult SendMessageToDonor([FromBody] MessageToDonorDTO dto)
 {
     return(Authorized(token =>
     {
         var contactId = _authenticationService.GetContactId(token);
         _gatewayDonationService.SendMessageToDonor(dto.DonorId, dto.DonationDistributionId, contactId, dto.Message, dto.TripName);
         return Ok();
     }));
 }
Example #3
0
        public IHttpActionResult Post()
        {
            return(Authorized(token =>
            {
                const String fileName = "profile.png";

                var contactId = _authenticationService.GetContactId(token);
                var files = _mpService.GetFileDescriptions("MyContact", contactId, token);
                var file = files.FirstOrDefault(f => f.IsDefaultImage);
                var base64String = Request.Content.ReadAsStringAsync().Result;

                if (base64String.Length == 0)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest, "Request did not specify a \"file\" for the profile image."));
                }

                var imageBytes = Convert.FromBase64String(base64String.Split(',')[1]);

                if (file != null)
                {
                    _mpService.UpdateFile(
                        file.FileId,
                        fileName,
                        "Profile Image",
                        true,
                        -1,
                        imageBytes,
                        token
                        );
                }
                else
                {
                    _mpService.CreateFile(
                        "MyContact",
                        contactId,
                        fileName,
                        "Profile Image",
                        true,
                        -1,
                        imageBytes,
                        token
                        );
                }
                return (Ok());
            }));
        }