public void UpdateReader(ReaderBusinessModel reader) { List <Tag> preferences = new List <Tag>(); if (reader.Preferences != null) { foreach (var tag in reader.Preferences) { preferences.Add(this.uow.Tags.GetById(tag.id)); } } Reader currentReader = uow.Readers.GetById(reader.ReaderId); if (reader.UserProfileBusiness != null) { UserProfile user = this.uow.UsersProfiles.GetById(reader.UserProfileBusiness.UserId); currentReader.UserProfile = user; } currentReader.Address = reader.Address; currentReader.Birthday = reader.Birthday; currentReader.EMail = reader.EMail; currentReader.FirstName = reader.FirstName; currentReader.LastName = reader.LastName; currentReader.Phone = reader.Phone; currentReader.Preferences = preferences; uow.Readers.Update(currentReader); uow.Commit(); }
public void GiveBookToStudent(ReaderHistoryBusinessModel readerHistoryBusinessModel) { ReaderHistoryMapper readerHistoryMapper = new ReaderHistoryMapper(); ReaderHistory readerHistory = new ReaderHistory(); readerHistory = readerHistoryMapper.Map(readerHistoryBusinessModel); Inventory inventory = this.uow.Inventories.GetAll().Where(inv => inv.Number == readerHistory.Inventory.Number).Select(inv => inv).Single(); if (inventory.IsAvailable == true) { inventory.IsAvailable = false; } else { throw new Exception(); } this.uow.Inventories.Update(inventory); uow.Commit(); }
public void UpdateScannedPage(ScannedPageBusinessModel scannedPage) { ScannedPage editScannedPage = uow.ScannedPages.GetById(scannedPage.Id); editScannedPage.Item.Id = scannedPage.Item.Id; editScannedPage.Reader.ReaderId = scannedPage.Reader.ReaderId; editScannedPage.OrderText = scannedPage.OrderText; editScannedPage.IsLocked = scannedPage.IsLocked; editScannedPage.IsReady = scannedPage.IsReady; if (scannedPage.IsReady) { editScannedPage.ExecutionDate = DateTime.Now; } editScannedPage.Message = scannedPage.Message; uow.ScannedPages.Update(editScannedPage); uow.Commit(); }