public EventFlag EditEventFlag(EventFlag eventFlag)
 {
     // Get original person object from database, no need to assig it to a variable
     GetEventFlag(eventFlag.EventFlagID);
     _entities.EventFlags.ApplyCurrentValues(eventFlag);
     _entities.SaveChanges();
     return eventFlag;
 }
 public bool DeleteEventFlag(EventFlag eventFlag)
 {
     try
     {
         _eventFlagRepository.DeleteEventFlag(eventFlag);
     }
     catch
     {
         return false;
     }
     return true;
 }
        public bool EditEventFlag(EventFlag eventFlag)
        {
            // Validation logic
            if (!ValidateEventFlag(eventFlag))
                return false;

            // Database logic
            try
            {
                _eventFlagRepository.EditEventFlag(eventFlag);
            }
            catch
            {
                return false;
            }
            return true;
        }
        public ActionResult EditEventFlag(EventFlag eventFlag)
        {
            // Validation logic
            _eventFlagService.ValidateEventFlag(eventFlag);
            if (!ModelState.IsValid)
                return View();

            try
            {
                _eventFlagService.EditEventFlag(eventFlag);
                return RedirectToAction("EventFlags", "Admin");
            }
            catch
            {
                return View();
            }
        }
 public bool ValidateEventFlag(EventFlag eventFlag)
 {
     if (eventFlag.FlagName.Trim().Length == 0)
         _validationDictionary.AddError("FlagName", "Flag name is required.");
     if (eventFlag.FlagYear == 0)
         _validationDictionary.AddError("FlagYear", "Flag year is required.");
     return _validationDictionary.IsValid;
 }
 public void DeleteEventFlag(EventFlag eventFlag)
 {
     var originalPerson = GetEventFlag(eventFlag.EventFlagID);
     _entities.EventFlags.DeleteObject(eventFlag);
     _entities.SaveChanges();
 }
 public EventFlag CreateEventFlag(EventFlag eventFlag)
 {
     _entities.AddToEventFlags(eventFlag);
     _entities.SaveChanges();
     return eventFlag;
 }
 /// <summary>
 /// Create a new EventFlag object.
 /// </summary>
 /// <param name="eventFlagID">Initial value of the EventFlagID property.</param>
 /// <param name="flagName">Initial value of the FlagName property.</param>
 /// <param name="flagYear">Initial value of the FlagYear property.</param>
 public static EventFlag CreateEventFlag(global::System.Int32 eventFlagID, global::System.String flagName, global::System.Int32 flagYear)
 {
     EventFlag eventFlag = new EventFlag();
     eventFlag.EventFlagID = eventFlagID;
     eventFlag.FlagName = flagName;
     eventFlag.FlagYear = flagYear;
     return eventFlag;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the EventFlags EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEventFlags(EventFlag eventFlag)
 {
     base.AddObject("EventFlags", eventFlag);
 }