Ejemplo n.º 1
0
        private VolunteerInfo GenerateOrganizerVolunteerInfo(int codeCampId)
        {
            var registration = RegistrationDataAccess.GetItemByUserId(UserInfo.UserID, codeCampId);

            if (registration == null)
            {
                RegistrationDataAccess.CreateItem(new RegistrationInfo()
                {
                    CodeCampId       = codeCampId,
                    IsRegistered     = true,
                    Notes            = "Registered automatically by Volunteer view.",
                    RegistrationDate = DateTime.Now,
                    ShirtSize        = "XL",
                    UserId           = UserInfo.UserID
                });

                registration = RegistrationDataAccess.GetItemByUserId(UserInfo.UserID, codeCampId);
            }

            VolunteerDataAccess.CreateItem(new VolunteerInfo()
            {
                CodeCampId     = codeCampId,
                Notes          = "Automatically generated by the Volunteer view.",
                RegistrationId = registration.RegistrationId
            });

            return(VolunteerDataAccess.GetItemByRegistrationId(registration.RegistrationId, codeCampId));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage CreateVolunteer(VolunteerInfo volunteer)
        {
            try
            {
                VolunteerDataAccess.CreateItem(volunteer);

                var savedVolunteer = VolunteerDataAccess.GetItemByRegistrationId(volunteer.RegistrationId, volunteer.CodeCampId);

                var response = new ServiceResponse <VolunteerInfo> {
                    Content = savedVolunteer
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }