예제 #1
0
        public JsonResult Delete(Entity_EmailAddressViewModel EmailAddressVM)
        {
            int ChangeCount = 0;

            using (Model.AnimalRescueEntities context = new Model.AnimalRescueEntities())
            {
                context.Connection.Open();

                ChangeCount = context.Entity_EmailAddressDelete(EmailAddressVM, true);

                context.Connection.Close();
            }

            var result = new { ChangeCount = ChangeCount };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public JsonResult Create(Entity_EmailAddressViewModel EmailAddress)
        {
            string ID          = "";
            int    ChangeCount = 0;

            using (Model.AnimalRescueEntities context = new Model.AnimalRescueEntities())
            {
                context.Connection.Open();

                ChangeCount = context.Entity_EmailAddressCreate(EmailAddress, out ID, true);

                context.Connection.Close();
            }

            var result = new { ChangeCount = ChangeCount, NewID = ID };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult Details(Guid ID)
        {
            var eventRegDB = new Event_Registration();
            var eventRegVM = new Event_RegistrationViewModel();

            using (Model.AnimalRescueEntities svc = new Model.AnimalRescueEntities())
            {
                svc.Connection.Open();

                eventRegDB = (from e in svc.Event_Registration
                              where e.ID.Equals(ID)
                              select e).Single();
                eventRegVM = Mapper.Map <Event_Registration, Event_RegistrationViewModel>(eventRegDB);

                svc.Connection.Close();
            }
            return(View(eventRegVM));
        }
예제 #4
0
        public FineUploaderResult UploadFile(FineUpload UploadedFile, Guid?EntityID, int?EntityType)
        {
            // 1) Save file to server
            //		save to the folder of the provided ID value
            //		return server path
            string             relativeFilePath = string.Empty;
            FineUploaderResult uploadResult     = SaveUploadedFile(UploadedFile, EntityID, EntityType, out relativeFilePath);

            // 2) Save file to database
            //		return
            Entity_FileViewModel File = new Entity_FileViewModel();

            switch (EntityType)
            {
            case 1:
                File.PersonID = EntityID;
                break;

            case 2:
                File.BusinessID = EntityID;
                break;

            case 3:
                File.DogID = EntityID;
                break;
            }
            File.ServerPath  = relativeFilePath;
            File.DateCreated = new DateTimeOffset(DateTime.Now, TimeSpan.FromHours(-6));
            File.ContentType = UploadedFile.ContentType;

            var context = new Model.AnimalRescueEntities();

            File.ID = context.Entity_FileCreate(File).ID;

            // 3) Return file ID and Server Path to client
            return(new FineUploaderResult(true, new
            {
                FileName = File.FileName,
                FileID = File.ID.ToString(),
                FilePath = File.ServerPath
            }));
        }
예제 #5
0
        public ActionResult CreateGolfReg(Event_RegistrationViewModel eventRegVM)
        {
            try
            {
                eventRegVM.Event_Attendee.RemoveAll(x => string.IsNullOrWhiteSpace(x.Entity_Person.FullName));
                eventRegVM.PlayerCount = eventRegVM.Event_Attendee.Count;
                eventRegVM.EventID     = Settings.Default.GolfTournament;

                using (Model.AnimalRescueEntities context = new Model.AnimalRescueEntities())
                {
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        context.Connection.Open();

                        //Retrieve the event
                        var eventDB = context.Events.Single(e => e.ID.Equals(Settings.Default.GolfTournament));

                        var eventRegDB = new Event_Registration();
                        eventRegDB         = Mapper.Map <Event_RegistrationViewModel, Event_Registration>(eventRegVM);
                        eventRegDB.EventID = eventDB.ID;

                        //Add the link between EVENT and REGISTRATION
                        context.AddToEvent_Registration(eventRegDB);

                        int  i          = 1;
                        Guid EventRegID = Guid.Empty;
                        foreach (var attendee in eventRegDB.Event_Attendee)
                        {
                            attendee.AttendeeType = 2;                             //Participant

                            if (i > 1)
                            {
                                attendee.EventRegistrationID = EventRegID;
                            }

                            context.AddToEvent_Attendee(attendee);
                            context.AddToEntity_Base(attendee.Entity_Person.Entity_Base);
                            context.AddToEntity_Person(attendee.Entity_Person);
                            foreach (var address in attendee.Entity_Person.Entity_Base.Entity_Addresses)
                            {
                                context.AddToEntity_Addresses(address);
                            }
                            foreach (var phone in attendee.Entity_Person.Entity_Base.Entity_PhoneNumber)
                            {
                                context.AddToEntity_PhoneNumber(phone);
                            }
                            foreach (var email in attendee.Entity_Person.Entity_Base.Entity_EmailAddress)
                            {
                                if (!string.IsNullOrWhiteSpace(email.Address) && !string.IsNullOrWhiteSpace(email.Type))
                                {
                                    context.AddToEntity_EmailAddress(email);
                                }
                            }

                            i++;
                        }
                        // Send the insert to the data service.
                        context.SaveChanges();
                        context.AcceptAllChanges();
                        transaction.Complete();
                    }
                }

                string body =
                    @"

Thank you for registering for the 1st Annual Texas Husky Rescue Golf Tournament Presented by 'Living Breathing Being - Life Coaching' (http://www.livingbreathingbeing.com/).

You can expect to receive an email closer to the tournament with further details.  If you have any questions prior to then, please feel free to contact us at this email address.	

Read more about the event and visit our other sponsors http://www.texashuskyrescue.org/mp/golf.aspx.

http://www.TexasHuskyRescue.org/ | http://www.facebook.com/texashuskyrescue | http://twitter.com/#!/txhuskyrescue 
1-877-TX-HUSKY (894-8759) (phone/fax)
PO Box 118891, Carrollton, TX 75011

";
                string contactEmail = Settings.Default.ContactEmail;
                foreach (var app in eventRegVM.Event_Attendee)
                {
                    if (!string.IsNullOrWhiteSpace(app.Entity_Person.Entity_Base.Entity_EmailAddress.Single().Address))
                    {
                        string subject = "Online Golf Registration for " + app.Entity_Person.FullName;
                        string email   = app.Entity_Person.Entity_Base.Entity_EmailAddress.Single().Address;
                        SendMailASES.SendEmail(contactEmail, email, subject, body, body, contactEmail);
                    }
                }

                string subjectGroup = "Online Golf Registration for ";
                string bodyGroup    = eventRegVM.DateSubmitted.ToShortDateString() + "\n\n";
                foreach (var app in eventRegVM.Event_Attendee)
                {
                    subjectGroup += app.Entity_Person.FullName;
                    if (eventRegVM.Event_Attendee.Count > 1)
                    {
                        subjectGroup += ", ";
                    }

                    bodyGroup += @"Name: " + app.Entity_Person.FullName + "\n";
                    bodyGroup += @"Email: " + app.Entity_Person.Entity_Base.Entity_EmailAddress.Single().Address + "\n";
                    bodyGroup += @"Address: " + app.Entity_Person.Entity_Base.Entity_Addresses.Single().AddressFull + "\n";
                    bodyGroup += @"Phone: " + app.Entity_Person.Entity_Base.Entity_PhoneNumber.Single().Number + "\n\n";
                }
                char[] charsToTrim = { ',', ' ' };
                subjectGroup = subjectGroup.TrimEnd(charsToTrim);
                SendMailASES.SendEmail(contactEmail, contactEmail, subjectGroup, bodyGroup, bodyGroup);

                return(RedirectToAction("ThankYou"));
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }
        }