Ejemplo n.º 1
0
        public OperationResult Remove(Event e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            var events = _serializer.Deserialize();

            if (events.All(ev => ev.Date.Date != e.Date.Date))
            {
                return new OperationResult {Success = false, Message = "Cannot find date given."};
            }

            _serializer.Serialize(new EventsList(events.Where(ev => ev.Date.Date != e.Date.Date).ToList()));

            return new OperationResult { Success = true };
        }
Ejemplo n.º 2
0
        public OperationResult Add(Event e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            var events = _serializer.Deserialize();

            if (events.Any(ev => ev.Date.Date == e.Date.Date))
            {
                return new OperationResult { Success = false, Message = "Error. This date already exist." };
            }

            events.Add(e);
            _serializer.Serialize(events);
            return new OperationResult { Success = true};
        }