Ejemplo n.º 1
0
        //
        // GET: /Register/Complete/RegUID
        public ActionResult Complete(string RegUID, FormCollection values)
        {
            if (RegUID == null)
            {
                ViewBag.Found = false;
                return View();
            }

            if (values.Count == 0)
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0)
                {
                    ViewBag.Found = true;
                    ViewBag.Scholarship = false;
                    ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
                    ViewBag.RegID = FoundRegID;
                    ViewBag.RegUID = RegUID;

                    return View();
                }
                else
                {
                    ViewBag.Found = false;
                    ViewBag.MessageEn = "Invalid Registration Key";
                    ViewBag.MessageCh = "没有找到登记";
                    return View();
                }
            }

            ViewBag.Found = false;
            return View();
        }
Ejemplo n.º 2
0
        //
        // GET: /Participant/HeadsetRequest/5?RegUID=xxx
        public ActionResult HeadsetRequest(string RegUID, int id = 0)
        {
            if (RegUID == null || id == 0)
            {
                ViewBag.Found = false;
                ViewBag.PartMessage = "Missing Necessary Parameters";
                return View();

            }
            else
            {
                var participantentry = from m in db.ParticipantEntries.Include(p => p.RegistrationEntries).
                    Include(p => p.Statuses).Include(p => p.Services).Include(p => p.AgeRanges).
                    Include(p => p.Genders).Include(p => p.RegTypes).Include(p => p.Fellowships).Include(p => p.RoomTypes).
                    Where(p => p.ParticipantID.Equals(id))
                                       select m;

                if (participantentry == null)
                {
                    ViewBag.Found = false;
                    ViewBag.PartMessage = "Participant not found";
                    return View();
                }
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int RegID = FoundEntry.RegUIDtoID(RegUID);

                if (RegID == 0)
                {
                    ViewBag.Found = false;
                    ViewBag.PartMessage = "Registration not found";
                    return View();
                }

                ParticipantEntry FoundPartEntry = new ParticipantEntry();
                FoundPartEntry = participantentry.FirstOrDefault();

                if (FoundPartEntry == null)
                {
                    return HttpNotFound();
                }

                if (FoundPartEntry.RegistrationID != RegID)
                {
                    ViewBag.Found = false;
                    ViewBag.PartMessage = "Participant not found";
                    return View();
                }

                ViewBag.Found = true;
                ViewBag.RegUID = RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ParticipantID = FoundPartEntry.ParticipantID;

                return View(FoundPartEntry);
            }
        }
        //
        // GET: /SearchRegistration/EditParticipant/5?RegUID
        public ActionResult EditParticipant(string RegUID, int id = 0)
        {
            if (RegUID == null || id == 0)
            {
                return RedirectToAction("Index", "Home");
            }

            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int RegID = FoundEntry.RegUIDtoID(RegUID);

                var participantentry = from m in db.ParticipantEntries.Include(p => p.RegistrationEntries).
                    Include(p => p.Statuses).Include(p => p.Services).Include(p => p.AgeRanges).
                    Include(p => p.Genders).Include(p => p.RegTypes).Include(p => p.Fellowships).Include(p => p.RoomTypes).
                    Where(p => p.ParticipantID.Equals(id))
                                       select m;

                if (participantentry == null || RegID == 0 || participantentry.FirstOrDefault().RegistrationID != RegID)
                {
                    return RedirectToAction("Index", "Home");
                }

                ViewBag.RegUID = RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ParticipantID = participantentry.FirstOrDefault().ParticipantID;

                ViewBag.StatusID = new SelectList(db.Statuses, "StatusID", "Name", participantentry.FirstOrDefault().StatusID);
                ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name", participantentry.FirstOrDefault().ServiceID);
                ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name", participantentry.FirstOrDefault().AgeRangeID);
                ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name", participantentry.FirstOrDefault().GenderID);
                ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name", participantentry.FirstOrDefault().RegTypeID);
                ViewBag.FellowshipID = new SelectList(db.Fellowships, "FellowshipID", "Name", participantentry.FirstOrDefault().FellowshipID);
                ViewBag.RoomTypeID = new SelectList(db.RoomTypes, "RoomTypeID", "Name", participantentry.FirstOrDefault().RoomTypeID);

                //ViewBag.ServiceID = new SelectList(db.Services.Where(p => p.ServiceID.Equals(participantentry.FirstOrDefault().ServiceID)), "ServiceID", "Name", participantentry.FirstOrDefault().ServiceID);
                //ViewBag.AgeRangeID = new SelectList(db.AgeRanges.Where(p => p.AgeRangeID.Equals(participantentry.FirstOrDefault().AgeRangeID)), "AgeRangeID", "Name", participantentry.FirstOrDefault().AgeRangeID);
                //ViewBag.GenderID = new SelectList(db.Genders.Where(p => p.GenderID.Equals(participantentry.FirstOrDefault().GenderID)), "GenderID", "Name", participantentry.FirstOrDefault().GenderID);
                //ViewBag.RegTypeID = new SelectList(db.RegTypes.Where(p => p.RegTypeID.Equals(participantentry.FirstOrDefault().RegTypeID)), "RegTypeID", "Name", participantentry.FirstOrDefault().RegTypeID);
                //ViewBag.FellowshipID = new SelectList(db.Fellowships.Where(p => p.ServiceID.Equals(participantentry.FirstOrDefault().ServiceID)), "FellowshipID", "Name", participantentry.FirstOrDefault().FellowshipID);
                //ViewBag.RoomTypeID = new SelectList(db.RoomTypes.Where(p => p.RegTypeID.Equals(participantentry.FirstOrDefault().RegTypeID)), "RoomTypeID", "Name", participantentry.FirstOrDefault().RoomTypeID);
                //ViewBag.PartPrice = participantentry.FirstOrDefault().PartPrice;

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(RegID, "Admin Participant Opened", participantentry.FirstOrDefault().ParticipantID);

                return View(participantentry.FirstOrDefault());
            }
        }
Ejemplo n.º 4
0
        public ActionResult Complete(string RegUID, PaymentEntry values)
        {
            if (RegUID == null)
            {
                ViewBag.Found = false;
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

            if (values.RegID == 0 && values.PaymentAmt == (decimal)0)
            {
                ViewBag.Found = true;
                ViewBag.Scholarship = true;
                ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
                ViewBag.RegID = FoundRegID;
                ViewBag.RegUID = RegUID;
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                return View(values);
            }

            if (values.RegID == FoundRegID && values.PaymentAmt <= (decimal)0)
            {
                ViewBag.Found = true;
                ViewBag.Scholarship = true;
                ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
                ViewBag.RegID = FoundRegID;
                ViewBag.RegUID = RegUID;
                ViewBag.MessageEn = "Please enter an Amount greater then 0";
                ViewBag.MessageCh = "请输入一个数目大于0";
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                return View(values);
            }

            if (values.RegID == FoundRegID && values.PaymentAmt > (decimal)0)
            {
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                _db.PaymentEntries.Add(values);
                _db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(values.RegID, "Scholarship Request Entered", values.PaymentID);

                return RedirectToAction("Modify", "Register", new { RegUID = RegUID });
            }

            ViewBag.Found = true;
            ViewBag.Scholarship = false;
            ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
            ViewBag.RegID = FoundRegID;

            return View();
        }
Ejemplo n.º 5
0
        //
        // POST: /Register/Unlock/RegUID
        public ActionResult Unlock(string RegUID, bool isAdmin = false)
        {
            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = RegUID;
                return View();
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0)
                {
                    var registrationentry = from m in _db.RegEntries.Where(p => p.RegistrationID.Equals(FoundRegID))
                                            select m;

                    ViewBag.Found = true;

                    FoundEntry = registrationentry.SingleOrDefault();
                    FoundEntry.IsConfirmed = false;

                    _db.Entry(FoundEntry).State = EntityState.Modified;

                    var PartEntry = from m in _db.ParticipantEntries.Include(p => p.RegistrationEntries).
                                   Include(p => p.Statuses).Include(p => p.Services).Include(p => p.AgeRanges).
                                   Include(p => p.Genders).Include(p => p.RegTypes).Include(p => p.Fellowships).Include(p => p.RoomTypes).
                                   Where(p => p.RegistrationID.Equals(FoundEntry.RegistrationID)).Where(p => !p.StatusID.Equals((int)4))
                                    select m;

                    foreach (ParticipantEntry FoundPart in PartEntry)
                    {
                        FoundPart.StatusID = (int)2;
                        _db.Entry(FoundPart).State = EntityState.Modified;
                    }
                    _db.SaveChanges();

                    if (isAdmin)
                    {
                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(FoundRegID, "Admin Registration Unlocked", 0);

                        return RedirectToAction("Detail", "SearchRegistration", new { Id = FoundRegID });
                    }
                    else
                    {
                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(FoundRegID, "General Registration Unlocked", 0);

                        return RedirectToAction("Modify", "Register", new { RegUID = RegUID });
                    }
                }
                else
                {
                    ViewBag.Found = false;
                    ViewBag.MessageEn = "Invalid Registration Key";
                    ViewBag.MessageCh = "没有找到登记";
                    return View();
                }
            }
        }
Ejemplo n.º 6
0
        //
        // GET: /Register/Modify/RegUID
        public ActionResult Modify(string RegUID)
        {
            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = RegUID;
                return RedirectToAction("Index", "Register");
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0)
                {
                    EventHistory NewEvent = new EventHistory();
                    NewEvent.AddHistory(FoundRegID, "General Registration Opened", 0);

                    ViewBag.Found = true;
                    ViewBag.RegID = FoundRegID;
                    return View();
                }
                else
                {
                    ViewBag.Found = false;
                    ViewBag.MessageEn = "Invalid Registration Key";
                    ViewBag.MessageCh = "没有找到登记";
                    return View();
                }
            }
        }
Ejemplo n.º 7
0
        public ActionResult Create(FormCollection values)
        {
            var order = new RegistrationEntry();

            TryUpdateModel(order);

            try
            {
                order.Email = order.Email.ToLower();
                order.Phone = new string(order.Phone.Where(c => char.IsDigit(c)).ToArray());

                if (_db.RegEntries.Any(e => e.Email == order.Email))
                {
                    ViewBag.MessageEn = "Email or Phone Number already exist";
                    ViewBag.MessageCh = "电子邮件或电话号码已经存在";
                    ViewBag.RegIsAllowed = true;
                    return View(order);
                }
                else if (_db.RegEntries.Any(e => e.Phone == order.Phone))
                {
                    ViewBag.MessageEn = "Email or Phone Number already exist";
                    ViewBag.MessageCh = "电子邮件或电话号码已经存在";
                    ViewBag.RegIsAllowed = true;
                    return View(order);
                }
                else
                {
                    ViewBag.Message = null;

                    Guid NewKey = System.Guid.NewGuid();

                    order.RegistrationUID = NewKey.ToString();

                    order.DateCreated = DateTime.Now;
                    order.IsConfirmed = false;

                    _db.RegEntries.Add(order);
                    _db.SaveChanges();

                    EventHistory NewEvent = new EventHistory();
                    NewEvent.AddHistory(order.RegUIDtoID(order.RegistrationUID), "New Registration Created", 0);

                    return RedirectToAction("Modify", "Participant", new { RegUID = order.RegistrationUID, isPage2 = false, id = 0 });
                    //return RedirectToAction("Index");
                }
            }
            catch
            {
                return View(order);
            }
        }
Ejemplo n.º 8
0
        public ActionResult RoomNoteAdd(string RegUID, bool isPage2, bool? isAdmin, int ID, RoomNote roomNote)
        {
            if (isAdmin == null)
            {
                isAdmin = false;
            }

            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View(roomNote);
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int RegID = FoundEntry.RegUIDtoID(RegUID);

            if (RegID == 0)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View(roomNote);
            }

            var findRoomNote = from m in db.RoomNotes.Where(p => p.PartID.Equals(ID))
                select m;

            if (findRoomNote.FirstOrDefault() == null)
            {

                roomNote.PartID = ID;

                db.RoomNotes.Add(roomNote);
                db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(RegID, "RoomNote Add", roomNote.RoomNoteID);

                return RedirectToAction("Modify", new { RegUID = RegUID, isPage2 = isPage2, id = ID });
            }
            else
            {
                RoomNote newRoomNote = findRoomNote.FirstOrDefault();

                newRoomNote.Note = roomNote.Note;

                db.Entry(newRoomNote).State = EntityState.Modified;
                db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(RegID, "RoomNote Add", newRoomNote.RoomNoteID);

                return RedirectToAction("Modify", new { RegUID = RegUID, isPage2 = isPage2, id = ID });
            }

            ViewBag.Found = false;
            ViewBag.Message = "Catchall Error";
            return View(roomNote);
        }
Ejemplo n.º 9
0
        //
        // GET: /Participant/RoomNoteAdd/UID
        public ActionResult RoomNoteAdd(string RegUID, bool isPage2 = false, bool? isAdmin = false, int Id = 0)
        {
            if (isAdmin == null)
            {
                isAdmin = false;
            }

            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int RegID = FoundEntry.RegUIDtoID(RegUID);

            if (RegID == 0)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            if (RegID != 0 && Id == 0)
            {
                ViewBag.Found = true;
                ViewBag.isNew = true;
                ViewBag.isPage2 = isPage2;
                ViewBag.RegUID = (string)RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name");
                ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name");
                ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name");
                ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name");

                return View();
            }

            if (RegID != 0 && Id != 0)
            {
                var participantentry = from m in db.ParticipantEntries.Include(p => p.RegistrationEntries).
                   Include(p => p.Statuses).Include(p => p.Services).Include(p => p.AgeRanges).
                   Include(p => p.Genders).Include(p => p.RegTypes).Include(p => p.Fellowships).Include(p => p.RoomTypes).
                   Where(p => p.ParticipantID.Equals(Id))
                                       select m;

                var roomNote = from m in db.RoomNotes.Where(p => p.PartID.Equals(Id))
                               select m;

                if (roomNote == null || RegID == 0)
                {
                    ViewBag.Found = false;
                    ViewBag.isNew = false;
                    ViewBag.isPage2 = isPage2;
                    ViewBag.isAdmin = isAdmin;
                    ViewBag.RegUID = RegUID;
                    ViewBag.RegistrationID = RegID;
                    ViewBag.ParticipantID = Id;

                    RoomNote returnRoomNote = new RoomNote();
                    returnRoomNote.Note = null;
                    returnRoomNote.PartID = Id;

                    return View(returnRoomNote);
                }

                ViewBag.Found = true;
                ViewBag.isNew = false;
                ViewBag.isPage2 = isPage2;
                ViewBag.isAdmin = isAdmin;
                ViewBag.RegUID = RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ParticipantID = Id;

                return View(roomNote.FirstOrDefault());
            }

            ViewBag.Found = false;
            ViewBag.Message = "Catchall Error";
            return View();
        }
Ejemplo n.º 10
0
        public ActionResult RoomNote(string RegUID, bool isPage2, bool? isAdmin, int Id, ParticipantEntry participantentry)
        {
            if (isAdmin == null)
            {
                isAdmin = false;
            }

            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int RegID = FoundEntry.RegUIDtoID(RegUID);

            if (RegID == 0)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            if (RegID != 0 && Id == 0)
            {

                ViewBag.Found = false;
                ViewBag.Message = "Invalid Participant ID";
                return View();
            }

            if (RegID != 0 && Id != 0)
            {
                if (isPage2)
                {
                    if (ModelState.IsValid && RegID != 0)
                    {
                        participantentry.RegistrationID = RegID;
                        participantentry.ParticipantID = Id;
                        participantentry.StatusID = (int)1;

                        RegPrice FoundPrice = new RegPrice();
                        participantentry.PartPrice = FoundPrice.PriceReturn(participantentry.AgeRangeID, participantentry.RegTypeID);

                        db.Entry(participantentry).State = EntityState.Modified;
                        db.SaveChanges();

                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(RegID, "RoomNote Add Page", participantentry.ParticipantID);

                        return RedirectToAction("RoomNoteAdd", new { RegUID = RegUID, isPage2 = true, id = participantentry.ParticipantID });
                    }

                    ViewBag.ServiceID = new SelectList(db.Services.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "ServiceID", "Name", participantentry.ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges.Where(p => p.AgeRangeID.Equals(participantentry.AgeRangeID)), "AgeRangeID", "Name", participantentry.AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders.Where(p => p.GenderID.Equals(participantentry.GenderID)), "GenderID", "Name", participantentry.GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RegTypeID", "Name", participantentry.RegTypeID);
                    ViewBag.FellowshipID = new SelectList(db.Fellowships.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "FellowshipID", "Name", participantentry.FellowshipID);
                    ViewBag.RoomTypeID = new SelectList(db.RoomTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RoomTypeID", "Name", participantentry.RoomTypeID);
                    ViewBag.PartPrice = participantentry.PartPrice;
                }
                else
                {
                    ViewBag.Found = false;
                    ViewBag.Message = "Invalid Participant ID";
                    return View();
                }

                ViewBag.Found = false;
                ViewBag.Message = "Invalid Participant ID";
                return View();

            }

            ViewBag.Found = false;
            ViewBag.Message = "Catchall Error";
            return View();
        }
Ejemplo n.º 11
0
        public ActionResult Remove(string RegUID, int id, ParticipantEntry participantentry)
        {
            int RegID = (int)0;

            if (RegUID == null)
            {
                ViewBag.PartMessage = "Participant not found";
                return RedirectToAction("Index", "Home");
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                RegID = FoundEntry.RegUIDtoID(RegUID);
            }

            if (ModelState.IsValid && RegID != 0)
            {
                participantentry.RegistrationID = RegID;
                participantentry.ParticipantID = id;
                participantentry.StatusID = (int)4;

                participantentry.PartPrice = (decimal)0;

                db.Entry(participantentry).State = EntityState.Modified;
                db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(RegID, "Participant Deleted", participantentry.ParticipantID);

                return RedirectToAction("Modify", "Register", new { RegUID = RegUID });
            }

            ViewBag.RegUID = RegUID;
            ViewBag.RegistrationID = RegID;
            ViewBag.ParticipantID = participantentry.ParticipantID;
            ViewBag.ServiceID = new SelectList(db.Services.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "ServiceID", "Name", participantentry.ServiceID);
            ViewBag.AgeRangeID = new SelectList(db.AgeRanges.Where(p => p.AgeRangeID.Equals(participantentry.AgeRangeID)), "AgeRangeID", "Name", participantentry.AgeRangeID);
            ViewBag.GenderID = new SelectList(db.Genders.Where(p => p.GenderID.Equals(participantentry.GenderID)), "GenderID", "Name", participantentry.GenderID);
            ViewBag.RegTypeID = new SelectList(db.RegTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RegTypeID", "Name", participantentry.RegTypeID);
            ViewBag.FellowshipID = new SelectList(db.Fellowships.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "FellowshipID", "Name", participantentry.FellowshipID);
            ViewBag.RoomTypeID = new SelectList(db.RoomTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RoomTypeID", "Name", participantentry.RoomTypeID);
            ViewBag.PartPrice = participantentry.PartPrice;

            return View(participantentry);
        }
Ejemplo n.º 12
0
        public ActionResult Modify(string RegUID, bool isPage2, bool? isAdmin, int Id, ParticipantEntry participantentry)
        {
            if (isAdmin == null)
            {
                isAdmin = false;
            }

            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int RegID = FoundEntry.RegUIDtoID(RegUID);

            if (RegID == 0)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            if (RegID != 0 && Id == 0)
            {
                if (ModelState.IsValid)
                {

                    participantentry.RegistrationID = RegID;
                    participantentry.StatusID = (int)1;
                    participantentry.FellowshipID = participantentry.ServiceID;
                    participantentry.RoomTypeID = participantentry.RegTypeID;

                    RegPrice FoundPrice = new RegPrice();
                    participantentry.PartPrice = FoundPrice.PriceReturn(participantentry.AgeRangeID, participantentry.RegTypeID);

                    db.ParticipantEntries.Add(participantentry);
                    db.SaveChanges();

                    EventHistory NewEvent = new EventHistory();
                    NewEvent.AddHistory(RegID, "New Participant Created", participantentry.ParticipantID);

                    return RedirectToAction("Modify", new { RegUID = RegUID, isPage2 = true, id = participantentry.ParticipantID });
                }

                ViewBag.Found = true;
                ViewBag.isNew = true;
                ViewBag.isPage2 = isPage2;
                ViewBag.RegUID = (string)RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name");
                ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name");
                ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name");
                ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name");

                return View();
            }

            if (RegID != 0 && Id != 0)
            {

                if (isPage2)
                {
                    if (ModelState.IsValid && RegID != 0)
                    {
                        participantentry.RegistrationID = RegID;
                        participantentry.ParticipantID = Id;
                        participantentry.StatusID = (int)2;

                        RegPrice FoundPrice = new RegPrice();
                        participantentry.PartPrice = FoundPrice.PriceReturn(participantentry.AgeRangeID, participantentry.RegTypeID);

                        db.Entry(participantentry).State = EntityState.Modified;
                        db.SaveChanges();

                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(RegID, "Participant Confirmed", participantentry.ParticipantID);

                        //return RedirectToAction("Modify", "Register", new { RegUID = RegUID });

                        if (participantentry.ServiceID == (int) 2 || participantentry.ServiceID == (int) 4)
                        {
                            return RedirectToAction("HeadsetRequest", "Participant",
                                             new {RegUID = RegUID, id = participantentry.ParticipantID});
                        }
                        else
                        {
                            return RedirectToAction("Modify", "Register", new { RegUID = RegUID });
                        }
                    }

                    ViewBag.ServiceID = new SelectList(db.Services.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "ServiceID", "Name", participantentry.ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges.Where(p => p.AgeRangeID.Equals(participantentry.AgeRangeID)), "AgeRangeID", "Name", participantentry.AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders.Where(p => p.GenderID.Equals(participantentry.GenderID)), "GenderID", "Name", participantentry.GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RegTypeID", "Name", participantentry.RegTypeID);
                    ViewBag.FellowshipID = new SelectList(db.Fellowships.Where(p => p.ServiceID.Equals(participantentry.ServiceID)), "FellowshipID", "Name", participantentry.FellowshipID);
                    ViewBag.RoomTypeID = new SelectList(db.RoomTypes.Where(p => p.RegTypeID.Equals(participantentry.RegTypeID)), "RoomTypeID", "Name", participantentry.RoomTypeID);
                    ViewBag.PartPrice = participantentry.PartPrice;
                }
                else
                {
                    if (ModelState.IsValid)
                    {
                        participantentry.RegistrationID = RegID;
                        participantentry.ParticipantID = Id;
                        participantentry.StatusID = (int)1;

                        var partFellowshipList = from m in db.Fellowships.Where(p => p.FellowshipID.Equals(participantentry.FellowshipID))
                                                 select m;
                        Fellowship partFellowship = partFellowshipList.FirstOrDefault();

                        try
                        {
                            if (partFellowship.ServiceID != participantentry.ServiceID)
                            {
                                participantentry.FellowshipID = participantentry.ServiceID;
                            }
                        }
                        catch
                        {
                        }

                        var partRoomTypeList = from m in db.RoomTypes.Where(p => p.RoomTypeID.Equals(participantentry.RoomTypeID))
                                               select m;
                        RoomType partRoomType = partRoomTypeList.FirstOrDefault();

                        try
                        {
                            if (partRoomType.RegTypeID != participantentry.RegTypeID)
                            {
                                participantentry.RoomTypeID = participantentry.RegTypeID;
                            }
                        }
                        catch
                        {
                        }

                        RegPrice FoundPrice = new RegPrice();
                        participantentry.PartPrice = FoundPrice.PriceReturn(participantentry.AgeRangeID, participantentry.RegTypeID);

                        db.Entry(participantentry).State = EntityState.Modified;
                        db.SaveChanges();

                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(RegID, "Participant Edited", participantentry.ParticipantID);

                        return RedirectToAction("Modify", new { RegUID = RegUID, isPage2 = true, id = participantentry.ParticipantID });
                    }

                    ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name", participantentry.ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name", participantentry.AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name", participantentry.GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name", participantentry.RegTypeID);
                }

                ViewBag.Found = true;
                ViewBag.isNew = false;
                ViewBag.isPage2 = isPage2;
                ViewBag.isAdmin = isAdmin;
                ViewBag.RegUID = RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ParticipantID = participantentry.ParticipantID;

                return View(participantentry);
            }

            ViewBag.Found = false;
            ViewBag.Message = "Catchall Error";
            return View();
        }
Ejemplo n.º 13
0
        //
        // GET: /Participant/Modify/RegUID
        public ActionResult Modify(string RegUID, bool isPage2 = false, bool? isAdmin = false, int Id = 0)
        {
            if (isAdmin == null)
            {
                isAdmin = false;
            }

            if (RegUID == null)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int RegID = FoundEntry.RegUIDtoID(RegUID);

            if (RegID == 0)
            {
                ViewBag.Found = false;
                ViewBag.Message = "Invalid Registration Key";
                return View();
            }

            if (RegID != 0 && Id == 0)
            {
                ViewBag.Found = true;
                ViewBag.isNew = true;
                ViewBag.isPage2 = isPage2;
                ViewBag.RegUID = (string)RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name");
                ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name");
                ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name");
                ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name");

                return View();
            }

            if (RegID != 0 && Id != 0)
            {
                 var participantentry = from m in db.ParticipantEntries.Include(p => p.RegistrationEntries).
                    Include(p => p.Statuses).Include(p => p.Services).Include(p => p.AgeRanges).
                    Include(p => p.Genders).Include(p => p.RegTypes).Include(p => p.Fellowships).Include(p => p.RoomTypes).
                    Where(p => p.ParticipantID.Equals(Id))
                                       select m;

                if (participantentry == null || RegID == 0 || participantentry.FirstOrDefault().RegistrationID != RegID)
                {
                    ViewBag.Found = false;
                    ViewBag.Message = "Participant not Found!";
                    return View();
                }

                ViewBag.Found = true;
                ViewBag.isNew = false;
                ViewBag.isPage2 = isPage2;
                ViewBag.isAdmin = isAdmin;
                ViewBag.RegUID = RegUID;
                ViewBag.RegistrationID = RegID;
                ViewBag.ParticipantID = participantentry.FirstOrDefault().ParticipantID;

                if (isPage2)
                {
                    ViewBag.ServiceID = new SelectList(db.Services.Where(p => p.ServiceID.Equals(participantentry.FirstOrDefault().ServiceID)), "ServiceID", "Name", participantentry.FirstOrDefault().ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges.Where(p => p.AgeRangeID.Equals(participantentry.FirstOrDefault().AgeRangeID)), "AgeRangeID", "Name", participantentry.FirstOrDefault().AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders.Where(p => p.GenderID.Equals(participantentry.FirstOrDefault().GenderID)), "GenderID", "Name", participantentry.FirstOrDefault().GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes.Where(p => p.RegTypeID.Equals(participantentry.FirstOrDefault().RegTypeID)), "RegTypeID", "Name", participantentry.FirstOrDefault().RegTypeID);
                    ViewBag.FellowshipID = new SelectList(db.Fellowships.Where(p => p.ServiceID.Equals(participantentry.FirstOrDefault().ServiceID)), "FellowshipID", "Name", participantentry.FirstOrDefault().FellowshipID);
                    ViewBag.RoomTypeID = new SelectList(db.RoomTypes.Where(p => p.RegTypeID.Equals(participantentry.FirstOrDefault().RegTypeID)), "RoomTypeID", "Name", participantentry.FirstOrDefault().RoomTypeID);
                    ViewBag.PartPrice = participantentry.FirstOrDefault().PartPrice;
                }
                else
                {
                    ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name", participantentry.FirstOrDefault().ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name", participantentry.FirstOrDefault().AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name", participantentry.FirstOrDefault().GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name", participantentry.FirstOrDefault().RegTypeID);
                }

                return View(participantentry.FirstOrDefault());
            }

            ViewBag.Found = false;
            ViewBag.Message = "Catchall Error";
            return View();
        }
        public ActionResult EditParticipant(string RegUID, int id, ParticipantEntry participantEntry)
        {
            if (RegUID == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0 && ModelState.IsValid)
                {

                    //participantEntry.RegistrationID = FoundRegID;

                    //var foundPartEntry = from m in db.ParticipantEntries.Include(p => p.RegistrationEntries).
                    //                                  Include(p => p.Statuses)
                    //                                 .Include(p => p.Services)
                    //                                 .Include(p => p.AgeRanges)
                    //                                 .
                    //                                  Include(p => p.Genders)
                    //                                 .Include(p => p.RegTypes)
                    //                                 .Include(p => p.Fellowships)
                    //                                 .Include(p => p.RoomTypes)
                    //                                 .
                    //                                  Where(p => p.RegistrationID.Equals(FoundRegID)).
                    //                                  Where(p => p.FirstName.Equals(participantEntry.FirstName)).
                    //                                  Where(p => p.LastName.Equals(participantEntry.LastName))
                    //                     select m;

                    //participantEntry.ParticipantID = foundPartEntry.FirstOrDefault().ParticipantID;
                    //foundPartEntry = null;

                    participantEntry.ParticipantID = id;
                    participantEntry.RegistrationID = FoundRegID;

                    db.Entry(participantEntry).State = EntityState.Modified;
                    db.SaveChanges();

                    EventHistory NewEvent = new EventHistory();
                    NewEvent.AddHistory(participantEntry.RegistrationID, "Admin Registration Edited", 0);

                    return RedirectToAction("Detail", "SearchRegistration", new { id = participantEntry.RegistrationID });
                }
                else
                {
                    ViewBag.RegUID = RegUID;
                    ViewBag.RegistrationID = participantEntry.RegistrationID;
                    ViewBag.ParticipantID = participantEntry.ParticipantID;

                    ViewBag.StatusID = new SelectList(db.Statuses, "StatusID", "Name", participantEntry.StatusID);
                    ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "Name", participantEntry.ServiceID);
                    ViewBag.AgeRangeID = new SelectList(db.AgeRanges, "AgeRangeID", "Name", participantEntry.AgeRangeID);
                    ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "Name", participantEntry.GenderID);
                    ViewBag.RegTypeID = new SelectList(db.RegTypes, "RegTypeID", "Name", participantEntry.RegTypeID);
                    ViewBag.FellowshipID = new SelectList(db.Fellowships, "FellowshipID", "Name", participantEntry.FellowshipID);
                    ViewBag.RoomTypeID = new SelectList(db.RoomTypes, "RoomTypeID", "Name", participantEntry.RoomTypeID);
                    return View(participantEntry);
                }
            }
        }
        public ActionResult EditRegistration(string RegUID, RegistrationEntry registrationentry)
        {
            if (RegUID == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0 && ModelState.IsValid)
                {

                    registrationentry.RegistrationID = FoundRegID;

                    db.Entry(registrationentry).State = EntityState.Modified;
                    db.SaveChanges();

                    EventHistory NewEvent = new EventHistory();
                    NewEvent.AddHistory(registrationentry.RegistrationID, "Admin Registration Edited", 0);

                    return RedirectToAction("Detail", "SearchRegistration", new { RegUID = registrationentry.RegistrationUID });
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
        }
        //
        // GET: /SearchRegistration/EditRegistration/RegUID
        public ActionResult EditRegistration(string RegUID)
        {
            if (RegUID == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                RegistrationEntry FoundEntry = new RegistrationEntry();
                int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

                if (FoundRegID != 0)
                {

                    var registrationentry = from m in db.RegEntries.Where(p => p.RegistrationID.Equals(FoundRegID))
                                            select m;
                    ViewBag.Message = "Edit Registration Detail";

                    return View(registrationentry.FirstOrDefault());
                }
                else
                {
                    ViewBag.Message = "Invalid Registration Key";
                    return View();
                }
            }
        }