protected override Organization Parse()
 {
     return(new Organization
     {
         Id = ToInt(OrganizationID),
         Name = OrganizationName.ToString(),
         About = About.ToString(),
         LastUpdate = ToDateTime(LastUpdate),
         Address = CompleteAddress.ToString(),
         StreetName = StreetName.ToString(),
         StreetNumber = ToInt(StreetNo),
         Barangay = Barangay.ToString(),
         City = CityOrMunicipality.ToString(),
         State = StateOrProvince.ToString(),
         Country = Country.ToString(),
         DateEstablished = DateEstablished.ToString(),
         ParentOrganization = ParentOrganization.ToString(),
         Preacher = FeastBuilderOrPreacher.ToString(),
         Branch = BranchOrLocation.ToString(),
         ContactNumber = ContactNo.ToString(),
         Email = EmailAddress.ToString(),
         Website = Website.ToString(),
         Longitude = (float)Convert.ToDouble(Longitude),
         Latitude = (float)Convert.ToDouble(Latitude),
         RetreatSchedule = RetreatSchedule.ToString(),
         RecollectionSchedule = RecollectionSchedule.ToString(),
         TalkSchedule = TalkSchedule.ToString(),
         CampSchedule = CampSchedule.ToString(),
         VolunteerSchedule = VolunteerSchedule.ToString(),
         OrgMasking = MaskingData.ToString()
     });
 }
示例#2
0
        public HttpResponseMessage AddSchedule(JObject saveBundle)
        {
            try
            {
                var houseId     = (Int32)saveBundle["houseId"];
                var eventId     = (Int32)saveBundle["eventId"];
                var shiftId     = (Int32)saveBundle["shiftId"];
                var volunteerId = 0;
                var volunteer   = new Volunteer();
                //verify all are > 0

                var schedule = new VolunteerSchedule();

                schedule.EventureId       = eventId;
                schedule.VolunteerShiftId = shiftId;
                schedule.DateCreated      = DateTime.Now;

                if (db.Volunteers.Any(v => v.ParticipantId == houseId))
                {
                    schedule.VolunteerId = db.Volunteers.SingleOrDefault(v => v.ParticipantId == houseId).Id;
                }
                else
                {
                    volunteer.ParticipantId = houseId;
                    volunteer.DateCreated   = DateTime.Now;
                    db.Volunteers.Add(volunteer);
                    schedule.VolunteerId = volunteer.Id;
                }

                db.VolunteerSchedules.Add(schedule);
                db.SaveChanges();


                //call mail
                //HttpResponseMessage result = new MailController().SendConfirmMail(order.Id);

                var resp = Request.CreateResponse(HttpStatusCode.OK);
                //resp.Content = new StringContent();
                resp.Content = new StringContent(schedule.Id.ToString(), Encoding.UTF8, "text/plain");
                return(resp);
            }
            catch (Exception ex)
            {
                //send quick email
                HttpResponseMessage result = new MailController().SendInfoMessage("*****@*****.**", "Error Handler_AddSchedule: " + ex.Message + "\n\n" + ex.InnerException);

                //regular log
                var logE = new EventureLog
                {
                    Message = "Error Handler: " + ex.Message + "\n\n" + ex.InnerException + " - bundle: " + saveBundle,
                    Caller  = "AddSchedule",
                    Status  = "ERROR",
                    LogDate = System.DateTime.Now.ToLocalTime()
                };
                db.EventureLogs.Add(logE);
                db.SaveChanges();

                if (Request != null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "There was error with your transaction, please try again."));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                }
            }
        }