public EventAJAX(Event evt) { this.EventName = evt.EventName; this.Date = evt.Date.ToString("MM/dd/yyyy"); this.MeetupLocation = evt.MeetupLocation; this.Notes = evt.Notes; string eventTimeAsString = evt.EventTime.ToString(); if(!String.IsNullOrEmpty(eventTimeAsString)) { int indexOfColon = eventTimeAsString.IndexOf(':'); this.EventHour = eventTimeAsString.Substring(0, indexOfColon); this.EventMinute = eventTimeAsString.Substring(indexOfColon + 1); //Now convert to Meridian time int eventHour = Convert.ToInt32(this.EventHour); string meridian = "AM"; if (eventHour > 12) { meridian = "PM"; int meridianHour = eventHour - 12; this.EventHour = meridianHour.ToString(); } this.EventMeridian = meridian; } }
public RestrictionReason EnforceEventRestrictionOnCharacter(Event eventInfo, CompleteCharacterData charInfo) { RestrictionReason restriction = new RestrictionReason().DefaultToUnrestricted(); //Enforce Game Restriction if (charInfo.GameID != eventInfo.GameID) { restriction.Restricted = true; restriction.Restricted_Reason = RestrictionReason.REASON_DOES_NOT_BELONG_TO_GAME; } //Enforce Game Restriction if (charInfo.ServerID != eventInfo.ServerID) { restriction.Restricted = true; restriction.Restricted_Reason = RestrictionReason.REASON_DOES_NOT_EXIST_ON_SERVER; } //Enforce Attendence Restriction EventInterface eventInterface = new EventInterface(LeetRaidsDB); IEnumerable<EventAttendee> evtAttendees = eventInterface.GetAllEventAttendees(eventInfo.EventID); if (evtAttendees.Any(attn => attn.CharacterID == charInfo.CharacterID)) { restriction.Restricted = true; restriction.Restricted_Reason = RestrictionReason.REASON_ALREADY_INVITED; } return restriction; }
public List<SearchCharacterResult> AddEventRestrictionsToCharacterInfo(List<SearchCharacterResult> characters, Event eventInfo) { RestrictionsInterface restrictionsInterface = new RestrictionsInterface(LeetRaidsDB); foreach (SearchCharacterResult c in characters) { c.Restriction = restrictionsInterface.EnforceEventRestrictionOnCharacter(eventInfo, c.CharacterInfo); } return characters; }
public bool AddNewEvent(Event evt) { bool success = false; evt.EventName = HttpUtility.HtmlEncode(evt.EventName); evt.MeetupLocation = HttpUtility.HtmlEncode(evt.MeetupLocation); evt.Notes = HttpUtility.HtmlEncode((evt.Notes.Length > 50) ? evt.Notes.SubStrMax(49) : evt.Notes); try { LeetRaidsDB.Events.InsertOnSubmit(evt); LeetRaidsDB.SubmitChanges(); success = true; } catch (Exception ex) { throw ex; } return success; }
public bool EditEvent(Event evtUpdateInfo) { bool valid = true; //Check if the game type for this event is valid for the game being added valid = (GetEventTypeByID(evtUpdateInfo.EventTypeID).GameID == evtUpdateInfo.GameID); bool success = false; if (valid) { Event editEvent = (from evt in LeetRaidsDB.Events where evt.EventID == evtUpdateInfo.EventID select evt).SingleOrDefault(); editEvent.Date = (evtUpdateInfo.Date != null) ? evtUpdateInfo.Date : editEvent.Date; editEvent.EventName = (!String.IsNullOrEmpty(evtUpdateInfo.EventName)) ? HttpUtility.HtmlEncode(evtUpdateInfo.EventName) : editEvent.EventName; //editEvent.EventRestrictionsID = (evtUpdateInfo.EventRestrictionsID != null) ? evtUpdateInfo.EventRestrictionsID : editEvent.EventRestrictionsID; editEvent.EventTime = (evtUpdateInfo.EventTime.Ticks > 0) ? evtUpdateInfo.EventTime : editEvent.EventTime; editEvent.EventTypeID = (evtUpdateInfo.EventTypeID != 0) ? evtUpdateInfo.EventTypeID : editEvent.EventTypeID; editEvent.MeetupLocation = (!String.IsNullOrEmpty(evtUpdateInfo.MeetupLocation)) ? HttpUtility.HtmlEncode(evtUpdateInfo.MeetupLocation) : editEvent.MeetupLocation; editEvent.Notes = (!String.IsNullOrEmpty(evtUpdateInfo.Notes)) ? HttpUtility.HtmlEncode(evtUpdateInfo.Notes.SubStrMax(99)) : editEvent.Notes; try { LeetRaidsDB.SubmitChanges(); success = true; } catch { } } return success; }
public List<SearchCharacterResult> SearchCharactersWithEventRestricitons(int gameID, string name, int? classID, int? roleID, int? factionID, int? serverID, int? levelMin, int? levelMax, Event eventInfo) { CharacterInterface charInterface = new CharacterInterface(LeetRaidsDB); List<SearchCharacterResult> characters = charInterface.SearchCharacters(gameID, name, classID, roleID, factionID, serverID, levelMin, levelMax).ToList(); return AddEventRestrictionsToCharacterInfo(characters, eventInfo); }
public JsonResult AddNewEventAJAX(string name, string date, string timeHour, string timeMin, string timeMeridian, string typeID, int charID, int roleID, string meetupLocation, string notes, string inHealRestriction, string inTankRestriction, string inDamageRestriction) { List<string> errors = new List<string>(); DateTime evtDate = new DateTime(); if (!DateTime.TryParse(date, out evtDate)) { errors.Add(Errors.DATE_INVALID); } //Validate that charID is for a character that belongs to the current member MemCharacter creatorCharacter = charInterface.GetCharacterByID(charID); if (creatorCharacter == null) { errors.Add(Errors.CHARACTER_NOT_FOUND); } //Validate Time TimeSpan eventTime = new TimeSpan(); string time = DataAccessLayer.Global.Global.ConvertMeridianTimeTo24Hour(timeHour, timeMin, timeMeridian); //if (!System.Text.RegularExpressions.Regex.IsMatch(time, @"[0-23]:[0-59]")) { errors.Add(Errors.TIME_INVALID); } if (!TimeSpan.TryParse(time, out eventTime)) { errors.Add(Errors.TIME_INVALID); } //Validate Role Restrictions string healerRestrictionInput = (!String.IsNullOrEmpty(inHealRestriction)) ? inHealRestriction : "0"; string tankRestrictionInput = (!String.IsNullOrEmpty(inTankRestriction)) ? inTankRestriction : "0"; string damageRestrictionInput = (!String.IsNullOrEmpty(inDamageRestriction)) ? inDamageRestriction : "0"; int healerRestriction = 0; if(!Int32.TryParse(healerRestrictionInput, out healerRestriction)) { errors.Add("Issue with Healer Restriction"); } int tankRestriction = 0; if (!Int32.TryParse(tankRestrictionInput, out tankRestriction)) { errors.Add("Issue with Tank Restriction"); } int damageRestriction = 0; if (!Int32.TryParse(damageRestrictionInput, out damageRestriction)) { errors.Add("Issue with Damage Restriction"); } //Need to handle event time better. If I wanted to make an hourly calendar how would that work bool success = false; if (errors.Count == 0) { //Add new Event Event evt = new Event() { Date = evtDate, EventCreaterMemberID = MemberInfo.MemberID, EventName = name, //EventRestrictionsID = null, EventTime = eventTime, EventTypeID = Convert.ToInt32(typeID), MeetupLocation = meetupLocation, Notes = notes, GameID = creatorCharacter.GameID, Active = true, ServerID = (int)creatorCharacter.ServerID }; success = eventInterface.AddNewEvent(evt); //If there is a serverID or a factionID go ahead and setup a basic restriction if (evt.ServerID != null || creatorCharacter.FactionID != null) { eventInterface.AddBasicRestrictions(evt.EventID, evt.ServerID, creatorCharacter.FactionID); } //Add Event Restrictions RoleRestriction[] roleRestrictions = new RoleRestriction[] { new RoleRestriction() { RoleID = 1, Quantity = damageRestriction}, new RoleRestriction() {RoleID = 2, Quantity = healerRestriction}, new RoleRestriction() {RoleID = 3, Quantity = tankRestriction} }; eventInterface.InsertRoleRestrictions(evt.EventID, roleRestrictions); //Creator is automatically added to the raid attendees CommitResponse autoMemberAddSuccess = eventInterface.AddNewEventAttendee(charID, evt.EventID, roleID, String.Empty, (int)ATTENDEE_STATUS.ACCEPTED, MemberInfo.MemberID); } else { //There was an issue with input } //Success Response return new JsonResult() { Data = success }; }
public ActionResult Edit(Event evt) { int charID = Convert.ToInt32(Request["Char"]); MemCharacter creatorCharacter = charInterface.GetCharacterByID(charID); //Add in sensetive data evt.EventID = CurrentEvent.EventID; evt.GameID = CurrentEvent.GameID; evt.EventTypeID = (evt.EventTypeID != 0) ? evt.EventTypeID : CurrentEvent.EventTypeID; evt.EventCreaterMemberID = CurrentEvent.EventCreaterMemberID; evt.ServerID = creatorCharacter.ServerID; string note = (!String.IsNullOrEmpty(Request["Note"])) ? Request["Note"] : String.Empty; int roleID = (!String.IsNullOrEmpty(Request["RoleID"])) ? Convert.ToInt32(Request["RoleID"]) : 0; //Add in Role Restriction Data string healerRestrictionInput = (!String.IsNullOrEmpty(Request["HealerRestriction"])) ? Request["HealerRestriction"] : "0"; string tankRestrictionInput = (!String.IsNullOrEmpty(Request["TankRestriction"])) ? Request["TankRestriction"] : "0"; string damageRestrictionInput = (!String.IsNullOrEmpty(Request["DamageRestriction"])) ? Request["DamageRestriction"] : "0"; int healerRestriction = 0; if (!Int32.TryParse(healerRestrictionInput, out healerRestriction)) { //errors.Add("Issue with Healer Restriction"); } int tankRestriction = 0; if (!Int32.TryParse(tankRestrictionInput, out tankRestriction)) { //errors.Add("Issue with Tank Restriction"); } int damageRestriction = 0; if (!Int32.TryParse(damageRestrictionInput, out damageRestriction)) { //errors.Add("Issue with Damage Restriction"); } bool success = eventInterface.EditEvent(evt); if (success) { eventInterface.UpdateAttendeeStatus(CurrentEvent.EventID, MemberInfo.MemberID, (int)ATTENDEE_STATUS.ACCEPTED, charID , note, roleID); //Updatee Restrictions RoleRestriction[] roleRestrictions = new RoleRestriction[] { new RoleRestriction() { RoleID = 1, Quantity = damageRestriction}, new RoleRestriction() {RoleID = 2, Quantity = healerRestriction}, new RoleRestriction() {RoleID = 3, Quantity = tankRestriction} }; eventInterface.UpdateRestrictions(CurrentEvent.EventID, roleRestrictions, evt.ServerID, creatorCharacter.FactionID); //eventInterface.UpdateRoleRestrictions(CurrentEvent.EventID, roleRestrictions); return RedirectToAction("Index"); } else { ModelState.AddModelError("Error", "Couldnt edit this event"); return View(); } }
public List<MemFriend> GetFriendsForMemberWithEventRestrictions(int memberID, Event eventInfo) { CharacterInterface charInterface = new CharacterInterface(LeetRaidsDB); //EventInterface eventInterface = new EventInterface(LeetRaidsDB); List<MemFriend> friends = (from friend in LeetRaidsDB.MemFriends where friend.MemberID == memberID select friend).ToList(); //Add in complete data foreach (MemFriend f in friends) { f.CompleteCharData = charInterface.GetCompleteCharacterByID(f.FriendCharacterID); } RestrictionsInterface restrictionInterface = new RestrictionsInterface(LeetRaidsDB); foreach (MemFriend friend in friends) { RestrictionReason restriction = restrictionInterface.EnforceEventRestrictionOnCharacter(eventInfo, friend.CompleteCharData); friend.Restricted = restriction.Restricted; friend.Reason = restriction.Restricted_Reason; } #region Old Filter which just removes user, doesn't say why //select new MemFriendWithEventRestriction() //{ // MemberID = friend.MemberID, // AddDateTime = friend.AddDateTime, // FriendCharacterID = friend.FriendCharacterID, // HighlightOnList = false, // MemFriendsID = friend.MemFriendsID, // Note = friend.Note, //}).ToList(); //if (charFilter == null) { charFilter = new int[0]; } //List<MemFriend> friends = (from friend in LeetRaidsDB.MemFriends // join friendChar in LeetRaidsDB.MemCharacters on friend.FriendCharacterID equals friendChar.CharacterID // where friend.MemberID == memberID // && friendChar.GameID == (gameIDFilter ?? friendChar.GameID) // && friendChar.ServerID == (serverIDFilter ?? friendChar.ServerID) // && !charFilter.Contains(friend.FriendCharacterID) // select friend).ToList(); #endregion return friends; }