Пример #1
0
        public ActionResult CreateOperation(Models.Operations.OperationInsert model)
        {
            Models.DB.Operation dbOperation = new Models.DB.Operation();
            Int32 operationId;

            dbOperation.OperationNumber = model.OperationNumber;
            dbOperation.SequenceNumber  = model.SequenceNumber;
            dbOperation.OperationStart  = model.Start;
            dbOperation.OperationEnd    = model.End;
            dbOperation.Title           = model.Title;
            dbOperation.Notes           = model.Notes;
            dbOperation.Created         = DateTime.UtcNow;

            try
            {
                _context.Operation.Add(dbOperation);
                _context.SaveChanges();
                operationId = dbOperation.OperationId;
            }
            catch (Exception exc)
            {
                throw exc;
            }

            return(RedirectToAction("Edit", new { id = operationId }));
        }
Пример #2
0
        public ActionResult CreateMember(Models.Membership.MemberInsert model)
        {
            Models.DB.Member dbMember = new Models.DB.Member();
            Int32            newID;

            dbMember.Address    = model.Address;
            dbMember.CapacityId = model.CapacityID;
            dbMember.City       = model.City;
            dbMember.Email      = model.Email;
            dbMember.FirstName  = model.FirstName;
            dbMember.Ham        = String.Empty;
            dbMember.Joined     = model.Joined;
            dbMember.LastName   = model.LastName;
            dbMember.PhoneCell  = model.PhoneCell;
            dbMember.PhoneHome  = model.PhoneHome;
            dbMember.PhoneWork  = model.PhoneWork;
            dbMember.State      = model.State;
            dbMember.Status     = String.Empty; //need to remove that from the db at some point
            dbMember.Zipcode    = model.Zip;

            if (dbMember.PhoneCell == null)
            {
                dbMember.PhoneCell = String.Empty;
            }
            if (dbMember.PhoneHome == null)
            {
                dbMember.PhoneHome = String.Empty;
            }
            if (dbMember.PhoneWork == null)
            {
                dbMember.PhoneWork = String.Empty;
            }

            if (dbMember.Ham == null)
            {
                dbMember.Ham = String.Empty;
            }

            try
            {
                _context.Member.Add(dbMember);
                _context.SaveChanges();
                newID = dbMember.MemberId;
            }
            catch (Exception exc)
            {
                throw exc;
            }



            return(View("Thanks", newID));
        }
Пример #3
0
        public ActionResult Edit(Models.Membership.MyInfoUpdate viewModel)
        {
            try
            {
                var loggedInMember = (from x in _context.Member
                                      where x.Email.ToLower() == User.Identity.Name.ToLower()
                                      select x).FirstOrDefault();

                if (loggedInMember == null)
                {
                    throw new Exception("Email address of logged in user not found in membership data.");
                }

                loggedInMember.FirstName = viewModel.FirstName;
                loggedInMember.LastName  = viewModel.LastName;
                loggedInMember.Address   = viewModel.Address;
                loggedInMember.City      = viewModel.City;
                loggedInMember.State     = viewModel.State;
                loggedInMember.Zipcode   = viewModel.Zip;
                loggedInMember.Email     = viewModel.Email;
                loggedInMember.PhoneHome = viewModel.PhoneHome ?? String.Empty;
                loggedInMember.PhoneCell = viewModel.PhoneCell ?? String.Empty;
                loggedInMember.PhoneWork = viewModel.PhoneWork ?? String.Empty;

                _context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Пример #4
0
        public ActionResult Initiate(Models.Callout.CalloutOccurrence model)
        {
            Services.Telephony t = new Services.Telephony(_applicationOptions, _config, _context);

            //send a text message
            var members = this.memberSummaryItems();

            t.SendCalloutHeadsupSMS(members);

            //save the new callout message
            Models.DB.Callout newCallout = new Models.DB.Callout();
            newCallout.Created        = DateTime.UtcNow;
            newCallout.CalloutMessage = model.VoiceMessage = model.VoiceMessage;

            _context.Callout.Add(newCallout);
            _context.SaveChanges();

            t.SendCalloutPhoneCallsandSMS(members, newCallout);

            return(View());
        }
Пример #5
0
        public ViewResult CreateOccurrence(Models.Training.TrainingClassInsert trainingClassInsert)
        {
            Models.DB.TrainingClass trainingClass = new TrainingClass();                                                         //the class itself
            List <Models.Training.TrainingClassParticipant> students    = new List <Models.Training.TrainingClassParticipant>(); //the students' participation in the above training class
            List <Models.Training.TrainingClassParticipant> instructors = new List <Models.Training.TrainingClassParticipant>(); //the instructors' participation in the above training class
            var x      = HttpContext.Request.Form;
            var thanks = new Models.Training.TrainingClassInsertConfirmation();

            Int32 i = 0;
            Int32 j = 0;

            //gross, but looping through the form data to find students/instructors/hours, not using binding for this
            foreach (var item in x)
            {
                if (item.Key == "member")
                {
                    foreach (var y in item.Value)
                    {
                        //gets the memberid
                        Models.Training.TrainingClassParticipant topi = new Models.Training.TrainingClassParticipant();
                        String maybememberid = y.ToString();
                        topi.MemberID = Int32.Parse(y.ToString());

                        //get the hours
                        string maybeHours = x["hours"][i];
                        topi.Hours = Decimal.Parse(maybeHours);

                        //keeping a counter so (above) we know how to find the hours by index. ie: for the third member, we look for the third set of hours.
                        students.Add(topi);
                        i = i + 1;
                    }
                }

                if (item.Key == "instructor")
                {
                    foreach (var y in item.Value)
                    {
                        //gets the memberid
                        Models.Training.TrainingClassParticipant topi = new Models.Training.TrainingClassParticipant();
                        String maybememberid = y.ToString();
                        topi.MemberID = Int32.Parse(y.ToString());

                        //get the hours
                        string maybeHours = x["ihours"][j];
                        topi.Hours = Decimal.Parse(maybeHours);

                        //keeping a counter so (above) we know how to find the hours by index. ie: for the third member, we look for the third set of hours.
                        instructors.Add(topi);
                        j = j + 1;
                    }
                }
            }


            trainingClass.Created                 = DateTime.UtcNow;
            trainingClass.TrainingDate            = trainingClassInsert.TrainingDate;
            trainingClass.TrainingId              = trainingClassInsert.TrainingID;
            trainingClass.TrainingClassStudent    = new List <TrainingClassStudent>();
            trainingClass.TrainingClassInstructor = new List <TrainingClassInstructor>();


            //parse the form and grab the instructors and students, along with their hours objects to store
            foreach (var item in students)
            {
                Models.DB.TrainingClassStudent trainingClassStudent = new TrainingClassStudent();

                trainingClassStudent.Created = DateTime.UtcNow;
                trainingClassStudent.TrainingClassStudentMemberId = item.MemberID;
                trainingClassStudent.TrainingClassStudentHours    = item.Hours;

                trainingClass.TrainingClassStudent.Add(trainingClassStudent);
            }

            foreach (var item in instructors)
            {
                Models.DB.TrainingClassInstructor trainingClassInstructor = new TrainingClassInstructor();

                trainingClassInstructor.Created = DateTime.UtcNow;
                trainingClassInstructor.TrainingClassInstructorMemberId = item.MemberID;
                trainingClassInstructor.TrainingClassStudentHours       = item.Hours;

                trainingClass.TrainingClassInstructor.Add(trainingClassInstructor);
            }


            try
            {
                _context.Add(trainingClass);
                _context.SaveChanges();
            }
            catch (Exception exc)
            {
                throw new Exception("Error saving new class (EF): " + exc.ToString());
            }


            var hours  = students.Sum(item => item.Hours).ToString();
            var people = students.Count.ToString();

            thanks.Message = "Great work, your team has added " + hours + " hours of training across " + people + " members.";

            return(View("TrainingOccurrenceInsertConfirmation", thanks));
        }