Пример #1
0
        public ActionResult JoinEvent(JoinEventModel model)
        {
            List<string> Error = new List<string>();

            int roleID = (!String.IsNullOrEmpty(Request["Role"])) ? Convert.ToInt32(Request["Role"]) : 0;
            if(roleID == 0)
            {
                Error.Add("Role Not Specified");
            }

            int charID = (!String.IsNullOrEmpty(Request["SelectedCharacter"])) ? Convert.ToInt32(Request["SelectedCharacter"]) : 0;
            if(charID == 0)
            {
                Error.Add("Character not Specified");
            }

            // Ensure the character exists on the same server as the evemt
            if (charInterface.GetCharacterByID(charID).ServerID != CurrentEvent.ServerID)
            {
                Error.Add("Character doesnt exist on same server as event");
            }

            //Enfore Role Restrictions
            if(roleID != 0 && eventInterface.IsRoleRestricted(CurrentEvent.EventID, roleID))
            {
                Error.Add("The role you selected is full");
            }

            if (Error.Count == 0)
            {
                MemCharacter memChar = charInterface.GetCharacterByID(charID);
                if (charInterface.ValidateUserRoles(memChar.ClassID, new int[] { roleID }))
                {
                    CommitResponse response = eventInterface.AddNewEventAttendee(charID, CurrentEvent.EventID, roleID, model.Note, model.AttendeeStatus, MemberInfo.MemberID);
                    if (response.success)
                    {
                        return RedirectToAction("Confirmation", "Shared");
                    }
                }
            }
            else
            {
                int eCount = 0;
                foreach(string e in Error)
                {
                    this.ModelState.AddModelError("Error" + eCount, e);
                }
            }

            model.UserCharacters = charInterface.GetAllMemberCharactersByGame(MemberInfo.MemberID, CurrentEvent.GameID).ToList();
            model.RestrictedRoles = eventInterface.GetRestrictedRolesThatAreFull(CurrentEvent.EventID).ToList();
            return View(model);
        }
Пример #2
0
 public ViewResult JoinEvent(int? gameID)
 {
     int intGameID = Convert.ToInt32(gameID);
     JoinEventModel model = new JoinEventModel();
     model.IsEventFull = eventInterface.IsEventFull(CurrentEvent.EventID);
     model.UserCharacters = (from memChar in charInterface.GetAllMemberCharactersByGame(MemberInfo.MemberID, intGameID)
                             where memChar.ServerID == (int)CurrentEvent.ServerID // Filter by characters which exists on the same server as the event
                             select memChar).ToList();
     model.RestrictedRoles = eventInterface.GetRestrictedRolesThatAreFull(CurrentEvent.EventID).ToList();
     model.CantJoinEventReason = (model.UserCharacters.Count > 0) ? null : GetReasonWhyUserCantJoinEvent(intGameID, (int)CurrentEvent.ServerID);
     return View(model);
 }