示例#1
0
        public LibraryLog Update(LibraryLog t)
        {
            LibraryLog f = Get(t.Id);

            if (f == null)
            {
                throw new ArgumentNullException($"Log Details with id {t.Id} does not exist or its deleted");
            }

            libraryLogs.Remove(t);


            if (t.Id <= 0)
            {
                throw new ArgumentException("Invalid Log Details Item Id");
            }

            f.BookNo         = t.BookNo;
            f.BookName       = t.BookName;
            f.MemberName     = t.MemberName;
            f.MobileNo       = t.MobileNo;
            f.Address        = t.Address;
            f.CheckedOutDate = t.CheckedOutDate;
            f.ReturnedDate   = t.ReturnedDate;



            f = DbStore.Save <LibraryLog>(f);

            return(f);
        }
示例#2
0
        public void Delete(long id)
        {
            LibraryLog r = Get(id);

            DbStore.Delete <LibraryLog>(r);
            libraryLogs.Remove(r);
        }
示例#3
0
        public LibraryLog Add(LibraryLog t)
        {
            if (!IsDuplicate(t))
            {
                t.Id = 0;
                var ret = DbStore.Save <LibraryLog>(t);

                if (ret != null)
                {
                    libraryLogs.Add(ret);
                }

                return(ret);
            }
            else
            {
                throw new DuplicateItemException("Log details already exists");
            }
        }
示例#4
0
 bool IsDuplicate(LibraryLog r)
 {
     return(libraryLogs.Exists(d => (d.BookNo == r.BookNo && d.Id == r.Id && d.CheckedOutDate == r.CheckedOutDate)));
 }