예제 #1
0
        public static LibraryRecordDetailDTO MapTo(LibraryRecord record)
        {
            var books = new List <BookRecordDTO>();

            foreach (var book in record.Books)
            {
                books.Add(new BookRecordDTO()
                {
                    id     = book.BookId.Value,
                    amount = book.BookAmount.Amount.ToString(),
                    title  = book.Title.Value
                });
            }

            return(new LibraryRecordDetailDTO()
            {
                Id = record.Id.Value,
                Books = books,
                CreatedDate = record.CreatedDate,
                IsExpired = DateTime.UtcNow > record.ReturnDate,
                ReturnFine = record.ReturnFine.Value,
                ReturnDate = record.ReturnDate,
                Username = record.User.Name + " " + record.User.Surname
            });
        }
        public void AddNewBook([FromBody] string bookName)
        {
            LibraryRecord newRecord = new LibraryRecord();

            newRecord.BookName = bookName;

            _ctx.LibraryRecords.Add(newRecord);
            _ctx.SaveChanges();
        }
예제 #3
0
 public void Insert(LibraryRecord libraryRecord)
 {
     try
     {
         dbcontext.LibraryRecordContext.Add(libraryRecord);
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #4
0
        public bool LoadModelIntoPrinter(LibraryRecord record, ModelLoadingManager.LoadFailedCallback onFailCallback)
        {
            Form1.debugLogger.Add("LoadModelIntoPrinter()", "loading model into printer.", DebugLogger.LogType.Secondary);
            var num = LoadModelIntoPrinter(record.cachefilename, onFailCallback) ? 1 : 0;

            if (num == 0)
            {
                return(num != 0);
            }

            Form1.debugLogger.Add("LoadModelIntoPrinter()", "Model loaded into printer.", DebugLogger.LogType.Secondary);
            Form1.debugLogger.Add("LoadModelIntoPrinter()", "OpenGL GetError(): " + GL.GetError().ToString() + ".", DebugLogger.LogType.Secondary);
            return(num != 0);
        }
예제 #5
0
 //删除
 public bool Delete(int ID)
 {
     try
     {
         LibraryRecord LibraryRecord = new LibraryRecord {
             LibraryRecordID = ID
         };
         dbcontext.LibraryRecordContext.Attach(LibraryRecord);
         dbcontext.LibraryRecordContext.Remove(LibraryRecord);
         //dbcontext.SaveChanges();
         return(true);
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         throw e;
     }
 }
예제 #6
0
 //更新IsPass状态
 public void UpdateIsPass(int ID, bool isPass)
 {
     try
     {
         LibraryRecord NewLibraryRecord = dbcontext.LibraryRecordContext.Find(ID);
         if (NewLibraryRecord == null)
         {
             return;
         }
         NewLibraryRecord.IsPass = isPass;
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #7
0
        public async Task Create(LibraryRecordCreateDTO libraryRecordDto)
        {
            var user = await userRepository.GetByIdAsync(new UserId(libraryRecordDto.userId));

            List <BookRecord> books = new List <BookRecord>();

            foreach (var book in libraryRecordDto.books)
            {
                var amount = Convert.ToInt32(book.amount);
                var bookId = new BookId(book.id);

                await CheckBookAvailibility(bookId, book.title,
                                            amount);

                books.Add(new BookRecord(bookId, new BookAmount(amount), new BookTitle(book.title)));
            }

            var libraryRecord = LibraryRecord.Create(UserMapper.MapTo(user), books);
            await libraryRecordRepository.InsertNewAsync(libraryRecord);
        }
예제 #8
0
 //更新借阅记录
 public bool Update(LibraryRecord libraryRecord)
 {
     try
     {
         LibraryRecord NewLibraryRecord = dbcontext.LibraryRecordContext.Find(libraryRecord.LibraryRecordID);
         NewLibraryRecord.BorrowTime   = libraryRecord.BorrowTime;
         NewLibraryRecord.ContractID   = libraryRecord.ContractID;
         NewLibraryRecord.EntryPerson  = libraryRecord.EntryPerson;
         NewLibraryRecord.IsPass       = libraryRecord.IsPass;
         NewLibraryRecord.ReturnTime   = libraryRecord.ReturnTime;
         NewLibraryRecord.SecrecyLevel = libraryRecord.SecrecyLevel;
         NewLibraryRecord.Sort         = libraryRecord.Sort;
         NewLibraryRecord.UserInfoID   = libraryRecord.UserInfoID;
         dbcontext.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }