public Book(string title, string description, EditionType editionType, decimal price, int copies, DateTime? releaseDate) { this.Title = title; this.Description = description; this.EditionType = editionType; this.Price = price; this.Copies = copies; this.ReleaseDate = releaseDate; }
public Book(int id, string title, string description, EditionType editionType, decimal price, int copies, DateTime? releaseDate, int authorId) { this.Id = id; this.Title = title; this.Description = description; this.EditionType = editionType; this.Price = price; this.Copies = copies; this.ReleaseDate = releaseDate; this.AuthorId = authorId; }
public void PutBook(int bookId, string title, string description, double price, int copies, DateTime releasedData, EditionType edition, int ageRestriction, int authorId) { var query = this.Data.Books.Find(bookId); var author = this.Data.Authors.Find(authorId); query.Title = title; query.Description = description; query.Edition = edition; query.ReleaseDate = releasedData; query.Price = price; query.Copies = copies; query.Author = author; query.AgeRestriction = ageRestriction; this.Data.SaveChanges(); }
private void SeedBooks(BookShopContext context) { int authorsCount = context.Authors.Local.Count; string[] books = File.ReadAllLines("../../Import/books.csv"); for (int i = 1; i < books.Length; i++) { string[] data = books[i] .Split(',') .Select(arg => arg.Replace("\"", string.Empty)) .ToArray(); int authorIndex = i % authorsCount; Author author = context.Authors.Local[authorIndex]; EditionType edition = (EditionType)int.Parse(data[0]); DateTime releaseDate = DateTime.ParseExact(data[1], "d/M/yyyy", CultureInfo.InvariantCulture); int copies = int.Parse(data[2]); decimal price = decimal.Parse(data[3]); AgeRestriction ageRestriction = (AgeRestriction)int.Parse(data[4]); string title = data[5]; Book book = new Book { Author = author, AuthorId = author.Id, EditionType = edition, ReleaseDate = releaseDate, Copies = copies, Price = price, AgeRestriction = ageRestriction, Title = title }; context.Books.AddOrUpdate(b => new { b.Title, b.AuthorId }, book); } }
public void IsEditionOf_IsTrue_IfOnlyTypeEditionOrYearAreDifferent(int edition, int year, EditionType type) { Book anotherEditionOfBook = new Book("1234") { Title = "The Clean Coder", SubTitle = "A Code of Conduct for Professional Programmers", Authores = new HashSet <string> { "Robert C. Martin" }, Edition = edition, Year = year, Publisher = "Prenctice Hall", Type = type }; Assert.That(anotherEditionOfBook, Is.Not.EqualTo(modelBook)); Assert.That(anotherEditionOfBook.IsEditionOf(modelBook), Is.True); Assert.That(modelBook.IsEditionOf(anotherEditionOfBook), Is.True); }
public ItemForm(EditionType editionType, int elementIndex) : this(editionType) { _saveButtonType = SaveButtonType.Update; _elementIndex = elementIndex; FillInTextBoxes(MainForm.BookShelf[elementIndex].ToString()); }
public Edition(string name, EditionType editionType) { Name = name; Type = editionType; _hash = Name.GetHashCode() + Type.GetHashCode(); }
//POST/api/books public void PostBook(string title, string description, double price, int copies, DateTime releasedData, EditionType edition, int AgeRestriction, string categoryNames) { Book newBook = new Book() { Title = title, Description = description, Edition = edition, ReleaseDate = releasedData, Price = price, Copies = copies, AgeRestriction = AgeRestriction }; string[] bookCategories = categoryNames.Split(' ').ToArray(); foreach (var category in bookCategories) { var currentCategory = this.Data.Categories.First(c => c.Name == category); newBook.Categories.Add(currentCategory); } this.Data.Books.Add(newBook); this.Data.SaveChanges(); }
// A Basic dictionary lookup //EpssApi.Edition GetEdition(string name) //{ // EpssApi.Edition edition = null; // if (this.fEditionsDictionary.ContainsKey(name)) // edition = (EpssApi.Edition)this.fEditionsDictionary.GetByIndex(fEditionsDictionary.IndexOfKey(name)); // return edition; //} //void MenuEditionClick(object obj, EventArgs ea) //{ // MenuItem aMenu = (MenuItem)obj; // // Using the title, find the edition // EpssApi.Edition edition = GetEdition(aMenu.Text); // // See if a view already exists for the edition. // // If it does not, then create a view for the edition // PLCView editionView = this.CreateEditionView(edition); // // Display the view for the specified edition // fClientPanel.SwitchToView(editionView); //} //void MenuChangeZoom(object obj, EventArgs ea) //{ // MenuItem aMenu = (MenuItem)obj; // switch (aMenu.Text) // { // case "100": // fScaleFactor.Width = 1; // fScaleFactor.Height = 1; // break; // case "150": // fScaleFactor.Width = 150; // fScaleFactor.Height = 150; // break; // case "200": // fScaleFactor.Width = 200; // fScaleFactor.Height = 200; // break; // } // // Draw the whole screen // fClientPanel.ZoomFactor = fScaleFactor.Width; // Size autoSize = new Size((int)Math.Ceiling(fScaleFactor.Width*1024), // (int)Math.Ceiling(fScaleFactor.Height*768)); // fClientPanel.AutoScrollMinSize = autoSize; // Invalidate(); //} //void MenuNewClick(object obj, EventArgs ea) //{ // Console.WriteLine("MenuNewClick"); // //fContentBrowser = new ContentBrowser(); // //fContentBrowser.DisplayContent("<html><head><body>Hello World!</body></head></html>"); // //fContentBrowser.Show(); //} /// <summary> /// This delegate routine is called when the 'Open' menu item is clicked. /// </summary> /// <param name="obj">A reference to the menu item that was clicked.</param> /// <param name="ea">The event arguments for the menu click</param> //void MenuOpenClick(object obj, EventArgs ea) //{ // if (fFileOpenDialog.ShowDialog() == DialogResult.OK) // { // fFileName = fFileOpenDialog.FileName; // LoadFile(fFileName); // } //} //void MenuSaveClick(object obj, EventArgs ea) //{ // Console.WriteLine("MenuSaveClick"); //} //void MenuSaveAsClick(object obj, EventArgs ea) //{ // //Console.WriteLine("MenuSaveAsClick"); // fSaveFileDialog.AddExtension = true; // fSaveFileDialog.FileName = fClientPanel.EditionName; // if (fSaveFileDialog.ShowDialog() == DialogResult.OK) // { // this.fClientPanel.SaveAs(fSaveFileDialog.FileName); // } //} //void MenuPageSetupClick(object obj, EventArgs ea) //{ // // Page Setup Dialog settings // setupDlg.Document = printDoc; // setupDlg.PageSettings = printDoc.DefaultPageSettings; // setupDlg.AllowMargins = false; // setupDlg.AllowOrientation = true; // setupDlg.AllowPaper = true; // setupDlg.AllowPrinter = true; // // Now pop up the dialog and capture the settings // if (setupDlg.ShowDialog() == DialogResult.OK) // { // printDoc.DefaultPageSettings = setupDlg.PageSettings; // printDoc.PrinterSettings = setupDlg.PrinterSettings; // } //} //void MenuPrintClick(object obj, EventArgs ea) //{ // printDlg.Document = printDoc; // printDlg.PrinterSettings.MinimumPage = 1; // printDlg.PrinterSettings.MaximumPage = 1; // printDlg.PrinterSettings.FromPage = 1; // printDlg.PrinterSettings.ToPage = 1; // if (printDlg.ShowDialog() == DialogResult.OK) // { // printDoc.DocumentName = Text; // printDoc.PrintPage += new PrintPageEventHandler(OnPrintPage); // // Do the actual printing thing // printDoc.Print(); // } //} //void OnPrintPage(object obj, PrintPageEventArgs ppea) //{ // // Create the graphics object to match the printer driver // Graphics grfx = ppea.Graphics; // // Now draw stuff // RootGraphic.DrawInto(grfx); // ppea.HasMorePages = false; //} PLCView CreateEditionView(EditionType edition) { PLCView aView = null; // Create a new view based on the stream of XML // and hand that back. switch (edition) { //case EditionType.Hardware: // aView = new PLCHardwareView(edition.Title,0,0,WExt.X, WExt.Y); // break; case EditionType.Software: aView = new PLCSoftwareView("Software",0,0,WExt.X, WExt.Y); break; //case EditionType.IT: // aView = new PLCITView(edition.Title,0,0,WExt.X, WExt.Y); // break; } //try { // XmlNode xNode = _ws.GeneratePLCMapXml (edition.EditionId); // aView.XmlData = xNode; //} catch //{ // Console.WriteLine("Error in loading XML from service: {0}",edition.EditionId); //} return aView; }
void CompleteEdition(EditionType editionType, Localisation localisation) { TempData[MiscHelpers.TempDataConstants.Info] = editionType == EditionType.Creation ? Worki.Resources.Views.Localisation.LocalisationString.LocHaveBeenCreate : Worki.Resources.Views.Localisation.LocalisationString.LocHaveBeenEdit; if (editionType == EditionType.Creation) { //send welcome mail if (!string.IsNullOrEmpty(localisation.Mail)) { var newMemberMailContent =string.Format(Worki.Resources.Email.Activation.LocalisationCreateContent, localisation.GetFullName(), Localisation.GetOfferType(localisation.TypeValue), localisation.City, localisation.GetDetailFullUrl(Url), localisation.GetFullName(), localisation.GetFullName()); var newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(localisation.Mail), string.Format(Worki.Resources.Email.Activation.LocalisationCreate, localisation.GetFullName()), WebHelper.RenderEmailToString("", newMemberMailContent)); _EmailService.Deliver(newMemberMail); } //need for pricing page TempData[MiscHelpers.TempDataConstants.NewLocalisationId] = localisation.ID; } }
public virtual ActionResult EditOffersEnd(int id, EditionType editionType) { var context = ModelFactory.GetUnitOfWork(); var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context); var mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var localisation = lRepo.Get(id); var member = mRepo.GetMember(User.Identity.Name); CompleteEdition(editionType, localisation); //if creation, put it online as everything is fine if (editionType == EditionType.Creation) { try { localisation.MainLocalisation.IsOffline = false; context.Commit(); } catch (Exception ex) { _Logger.Error("EditOffersEnd", ex); context.Complete(); return RedirectToAction(MVC.Home.Error()); } } var newContext = ModelFactory.GetUnitOfWork(); lRepo = ModelFactory.GetRepository<ILocalisationRepository>(newContext); localisation = lRepo.Get(id); if (!Roles.IsUserInRole(member.Username, MiscHelpers.BackOfficeConstants.BackOfficeRole) && !localisation.IsSharedOffice()) { return RedirectToAction(MVC.Home.Pricing()); } else { return Redirect(localisation.GetDetailFullUrl(Url)); } }
public virtual ActionResult EditOffers(int id, EditionType editionType) { var context = ModelFactory.GetUnitOfWork(); var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context); var localisation = lRepo.Get(id); if (localisation == null) { TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Localisation.LocalisationString.WorkplaceNotFound; return RedirectToAction(MVC.Home.Index()); } return View(new OfferCounterModel(localisation) { EditionType = editionType }); }