public void addEventByItemAndPerson(Item item, Person person)
        {
            StateDescription state = new StateDescription(item);
            Event            tmp   = new Event(state, person, DateTime.Now);

            DataRepository.addEvent(tmp);
        }
Beispiel #2
0
 public void updateStateDescription(int Id, StateDescription state)
 {
     if (Id > DataCtx.StatesCatalog.Count - 1 || Id < 0)
     {
         throw new KeyNotFoundException("StatesCatalog does not contain such ID - \"" + Id + "\"");
     }
     DataCtx.StatesCatalog[Id] = state;
 }
        public List <Event> getAllEventsByStateDescription(StateDescription state)
        {
            List <Event> tmp = DataRepository.getAllEvents();
            List <Event> res = new List <Event>();

            foreach (Event ev in tmp)
            {
                if (ev.StateDescription == state)
                {
                    res.Add(ev);
                }
            }
            return(res);
        }
Beispiel #4
0
 public Event(StateDescription stateDescription, Person person, DateTime hireDate)
 {
     StateDescription = stateDescription;
     Person           = person;
     HireDate         = hireDate;
 }
Beispiel #5
0
 public Rental(StateDescription stateDescription, Person person, DateTime hireDate) :
     base(stateDescription, person, hireDate)
 {
     ReturnDate = null;
 }
Beispiel #6
0
        // StateDescription C.R.U.D. methods

        public void addStateDescription(StateDescription state)
        {
            DataCtx.StatesCatalog.Add(state);
        }
 public void updateStateDescription(int Id, StateDescription state)
 {
     DataRepository.updateStateDescription(Id, state);
 }
 public void addStateDescription(StateDescription state)
 {
     DataRepository.addStateDescription(state);
 }
        public void addEventByStateAndPerson(StateDescription state, Person person)
        {
            Event tmp = new Event(state, person, DateTime.Now);

            DataRepository.addEvent(tmp);
        }
        public void addStateDescriptionByItem(Item item)
        {
            StateDescription tmp = new StateDescription(item);

            DataRepository.addStateDescription(tmp);
        }
Beispiel #11
0
        public static DataContext Deserialize(string filename)
        {
            DataContext     dataContext = new DataContext();
            SerializeHelper helper      = new SerializeHelper();
            string          data        = System.IO.File.ReadAllText(filename);

            var dataList = data.Split('\n');

            for (int i = 0; i < dataList.Length; i++)
            {
                if (!string.IsNullOrEmpty(dataList[i]))
                {
                    var splittedLine = dataList[i].Split(',');

                    Type   type = Type.GetType(splittedLine[0]);
                    object obj  = Activator.CreateInstance(type);

                    switch (splittedLine[0])
                    {
                    case "Library.Person":
                        Person person = (Person)obj;
                        person.Deserialize(splittedLine, helper);
                        helper.PeopleDictionary.Add(splittedLine[1], person);
                        dataContext.PeopleCatalog.Add(person);
                        break;

                    case "Library.Reader":
                        Reader reader = (Reader)obj;
                        reader.Deserialize(splittedLine, helper);
                        helper.PeopleDictionary.Add(splittedLine[1], reader);
                        dataContext.PeopleCatalog.Add(reader);
                        break;

                    case "Library.Author":
                        Author author = (Author)obj;
                        author.Deserialize(splittedLine, helper);
                        helper.PeopleDictionary.Add(splittedLine[1], author);
                        dataContext.PeopleCatalog.Add(author);
                        break;

                    case "Library.Item":
                        Item item = (Item)obj;
                        item.Deserialize(splittedLine, helper);
                        helper.ItemsDictionary.Add(splittedLine[1], item);
                        dataContext.ItemsCatalog.Add(item.Id, item);
                        break;

                    case "Library.Book":
                        Book book = (Book)obj;
                        book.Deserialize(splittedLine, helper);
                        helper.ItemsDictionary.Add(splittedLine[1], book);
                        dataContext.ItemsCatalog.Add(book.Id, book);
                        break;

                    case "Library.StateDescription":
                        StateDescription stateDescription = (StateDescription)obj;
                        stateDescription.Deserialize(splittedLine, helper);
                        helper.StatesDictionary.Add(splittedLine[1], stateDescription);
                        dataContext.StatesCatalog.Add(stateDescription);

                        break;

                    case "Library.BookDescription":
                        BookDescription bookDescription = (BookDescription)obj;
                        bookDescription.Deserialize(splittedLine, helper);
                        helper.StatesDictionary.Add(splittedLine[1], bookDescription);
                        dataContext.StatesCatalog.Add(bookDescription);
                        break;

                    case "Library.Event":
                        Event ev = (Event)obj;
                        ev.Deserialize(splittedLine, helper);
                        dataContext.EventsCatalog.Add(ev);
                        break;

                    case "Library.Rental":
                        Rental rental = (Rental)obj;
                        rental.Deserialize(splittedLine, helper);
                        dataContext.EventsCatalog.Add(rental);
                        break;
                    }
                }
            }
            return(dataContext);
        }