public void AddEventType(EventType newType)        
        {
            if (ShortTitleExisting(newType))
                throw new DuplicatedShortTitleException(newType);

            int id = (eventTypes.Count > 0) ? eventTypes.Max(f => f.Id) : 0;
            newType.Id = ++id;
            eventTypes.Add(newType);
        }
        public void EditEventType(EventType aType)
        {
            if (ShortTitleExisting(aType))
                throw new DuplicatedShortTitleException(aType);

            EventType item = FindEventType(aType.Id);

            item.TitleShort = aType.TitleShort;
            item.Title = aType.Title;
            item.Description = aType.Description;
        }
 public ActionResult AddEventType(EventType aEvent)
 {
     try
     {
         eventTypeManager.AddEventType(aEvent);
         return RedirectToAction("Index");
     }
     catch (DuplicatedShortTitleException e)
     {
         ModelState.AddModelError("TitleShort", e.Message);                
     }
     catch(Exception e)
     {
         ModelState.AddModelError("UnknownError", e);
     }
     return View("AddEventType", aEvent);
 }
Esempio n. 4
0
 public TypedEventItem(string titel, string description, int id)
     : base(titel, description, id)
 {
     Type = null;
 }
Esempio n. 5
0
 public TypedEventItem()
     : base()
 {
     Type = null;
 }
Esempio n. 6
0
        public override EventItem CopyItem(EventItem item)
        {
            base.CopyItem(item);
            TypedEventItem typeItem = item as TypedEventItem;
            if(typeItem != null)
                Type = typeItem.Type;

            return this;
        }
 public DuplicatedShortTitleException(EventType type) : base(string.Format("Short titel {0} alread exists.", type.TitleShort)) { }
 private bool ShortTitleExisting(EventType aType)
 {
     return eventTypes.Exists(f => f.TitleShort == aType.TitleShort);
 }