public TextBookViewModel(TextBook aTextBook) { UniversityId = aTextBook.UniversityId; TextBookId = aTextBook.Id; BookTitle = aTextBook.BookTitle; ClassSubject = aTextBook.ClassSubject; ClassCourse = aTextBook.ClassCourse; Edition = aTextBook.Edition.ToString(); Price = aTextBook.Price.ToString(); Details = aTextBook.Details; TextBookImageUrl = PhotoHelper.TextBookPhoto(aTextBook); BookAuthor = aTextBook.BookAuthor; ISBN = aTextBook.ISBN; }
public void UpdateTextBook(TextBook aTextBook) { theEntities.ApplyCurrentValues(aTextBook.EntityKey.EntitySetName, aTextBook); theEntities.SaveChanges(); }
public static string BuildTextbookUrl(TextBook aTextbook) { return "/" + aTextbook.UniversityId + "/TextBook/Details/" + aTextbook.Id; }
/// <summary> /// Create a new TextBook object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="universityId">Initial value of the UniversityId property.</param> /// <param name="textBookConditionId">Initial value of the TextBookConditionId property.</param> /// <param name="bookTitle">Initial value of the BookTitle property.</param> /// <param name="bookAuthor">Initial value of the BookAuthor property.</param> /// <param name="edition">Initial value of the Edition property.</param> /// <param name="price">Initial value of the Price property.</param> /// <param name="dateTimeStamp">Initial value of the DateTimeStamp property.</param> /// <param name="active">Initial value of the Active property.</param> public static TextBook CreateTextBook(global::System.Int32 id, global::System.Int32 userId, global::System.String universityId, global::System.String textBookConditionId, global::System.String bookTitle, global::System.String bookAuthor, global::System.Int32 edition, global::System.Double price, global::System.DateTime dateTimeStamp, global::System.Boolean active) { TextBook textBook = new TextBook(); textBook.Id = id; textBook.UserId = userId; textBook.UniversityId = universityId; textBook.TextBookConditionId = textBookConditionId; textBook.BookTitle = bookTitle; textBook.BookAuthor = bookAuthor; textBook.Edition = edition; textBook.Price = price; textBook.DateTimeStamp = dateTimeStamp; textBook.Active = active; return textBook; }
/// <summary> /// Deprecated Method for adding a new object to the TextBooks EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTextBooks(TextBook textBook) { base.AddObject("TextBooks", textBook); }
private void UpdateTextBookPhoto(string anId, HttpPostedFileBase aTextBookImage, TextBook aTextBook) { string myImageName = string.Empty; try { myImageName = AWSPhotoHelper.TakeImageAndResizeAndUpload(aTextBookImage, AWSHelper.GetClient(), SiteConfiguration.TextbookPhotosBucket(), anId, TextBookConstants.BOOK_MAX_SIZE); } catch (Exception myException) { throw new PhotoException("Error while resizing and uploading the textbook photo. ", myException); } try { aTextBook.BookPicture = myImageName; theTextBookRepo.UpdateTextBook(aTextBook); } catch (Exception myException) { AWSPhotoHelper.PhysicallyDeletePhoto(AWSHelper.GetClient(), SiteConfiguration.TextbookPhotosBucket(), myImageName); throw new CustomException("Error while updating the textbook to the new textbook photo.", myException); } }