private bool IsCountAs(DVD profile)
        {
            var result = profile.CountAs == Value;

            return(result);
        }
Ejemplo n.º 2
0
 public void Edit(int id, DVD dvd)
 {
     DVDRepo.Update(dvd);
 }
Ejemplo n.º 3
0
 protected void gridDVDS_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     gridDVDS.PageIndex  = e.NewPageIndex;
     gridDVDS.DataSource = DVD.List();
     gridDVDS.DataBind();
 }
Ejemplo n.º 4
0
 public IHttpActionResult Create(DVD dvd)
 {
     _dvdRepository.Create(dvd);
     return(Created($"dvd/{dvd.DvdId}", dvd));
 }
Ejemplo n.º 5
0
 public void Edit(DVD dvd)
 {
     Delete(dvd.Id);
     _dvds.Add(dvd);//Edit based on ID match
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Client
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            #region Abstract Factory
            Console.WriteLine("Abstract Factory initialize");

            //Step 1
            SqlCommand   cmd = new SqlCommand();
            SqlConection cnn = new SqlConection();
            cmd.Execute();

            //Apply Abstract Factory pattern
            DbFactory db  = new OracleFactory();
            var       con = db.createConnection();
            con.Open();
            var command = db.createCommand();
            command.Execute();

            Console.WriteLine("Abstract Factory finalize" + Environment.NewLine);
            #endregion

            #region Builder
            Console.WriteLine("Builder initialize");

            //Step 1
            var car = new Auto("Car");
            car["gear"]  = "127c";
            car["doors"] = "4";
            car["tires"] = "4";
            car.Show();
            Console.ReadLine();

            var bike = new Auto("bike");
            bike["gear"]  = "50c";
            bike["doors"] = "0";
            bike["tires"] = "2";
            bike.Show();
            Console.ReadLine();

            //Apply Builder pattern
            AutoBuilder builder;
            var         director = new Director();

            builder = new CarBuilder();
            director.Construct(builder);
            builder.Auto.Show();

            builder = new BikeBuilder();
            director.Construct(builder);
            builder.Auto.Show();

            Console.WriteLine("Builder finalize" + Environment.NewLine);
            #endregion

            #region Factory
            Console.WriteLine("Factory Method Initialize");

            //Step 1
            var login = new AuthGoogle();
            login.Authorize();
            Console.ReadLine();

            //Apply Factory
            Creator[] creators = new Creator[2];
            creators[0] = new FacebookCreator();
            creators[1] = new GoogleCreator();

            foreach (Creator c in creators)
            {
                Auth aut = c.CreateInstance(); //Factory Method
                aut.Authorize();
            }
            Console.ReadLine();

            Console.WriteLine("Factory Finalize" + Environment.NewLine);
            #endregion

            #region Prototype
            Console.WriteLine("Prototype initialize");
            Book p1 = new Book(1, "Design Patterns - Book", 20.00);
            Book c1 = (Book)p1.Clone();
            Console.WriteLine(c1.Description);

            DVD p2 = new DVD(2, "Design Patterns - DVD", 25.00);
            DVD c2 = (DVD)p2.Clone();
            Console.WriteLine(c2.Description);
            Console.WriteLine("Prototype Finalize" + Environment.NewLine);
            Console.ReadKey();
            #endregion

            #region Singleton
            Console.WriteLine("Singleton Initialize");
            var con1 = ConnectionBD.Instance();
            con1.stringConexao = "SQLServer";
            con1.Open();
            var con2 = ConnectionBD.Instance();
            con2.stringConexao = "Oracle";
            con2.Open();

            if (con1.Equals(con2))
            {
                Console.WriteLine("Equals Instances");
            }

            Console.WriteLine("Singleton Finalize" + Environment.NewLine);
            Console.ReadKey();
            #endregion
        }
Ejemplo n.º 7
0
        /// <summary>
        /// ISP: The client should not be forced to depend on intefaces they don't use.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            IBorrowableDVD dvd = new DVD();

            Console.ReadLine();
        }
        private static bool HasEasterEggs(DVD profile)
        {
            var result = !string.IsNullOrWhiteSpace(profile.EasterEggs);

            return(result);
        }
        private bool IsSRPCurrency(DVD profile)
        {
            var result = profile.SRP.IsCurrency(Value);

            return(result);
        }
        private static bool HasSRPrice(DVD profile)
        {
            var result = profile.SRP.CheckValue();

            return(result);
        }
        private static bool HasSRPCurrency(DVD profile)
        {
            var result = profile.SRP.HasCurrency();

            return(result);
        }
        private bool IsCaseType(DVD profile)
        {
            var result = profile.CaseType.IsExpected(Value);

            return(result);
        }
        private static bool HasCaseType(DVD profile)
        {
            var result = !string.IsNullOrWhiteSpace(profile.CaseType);

            return(result);
        }
        private static bool HasOverview(DVD profile)
        {
            var result = !string.IsNullOrWhiteSpace(profile.Overview);

            return(result);
        }
        private static bool HasAspectRatio(DVD profile)
        {
            var result = profile.Format != null && !string.IsNullOrWhiteSpace(profile.Format.AspectRatio);

            return(result);
        }
        private bool HasTag(DVD profile)
        {
            var result = profile.TagList.HasTagName(Value);

            return(result);
        }
Ejemplo n.º 17
0
 public ActionResult DeleteDVD(DVD dvd)
 {
     _dvdManager.Delete(dvd.DvdId);
     return(RedirectToAction("Collection"));
 }
        private static bool HasCollectionNumber(DVD profile)
        {
            var result = !string.IsNullOrWhiteSpace(profile.CollectionNumber);

            return(result);
        }
Ejemplo n.º 19
0
 public PlayerFacade(DVD dvd, IPlayer dvdPlayer)
 {
     _dvd       = dvd;
     _dvdPlayer = dvdPlayer;
 }
        private static bool HasRunningTime(DVD profile)
        {
            var result = profile.RunningTime > 0;

            return(result);
        }
Ejemplo n.º 21
0
        public void LoadRows()
        {
            Image im = Image.FromFile(@"C:\Users\Cleveland Codes\Pictures\images\005.gif");

            byte[] pic = ImageToByteArray(im);

            DVD mov1 = new DVD
            {
                Title        = "Spirited Away",
                ReleaseDate  = new DateTime(1993, 09, 04),
                Price        = 2.59M,
                Genre        = "Anime",
                Actor        = " Daveigh Chase, Suzanne Pleshette, Miyu Irino",
                Rating       = "PG",
                Description  = "During her family's move to the suburbs, a sullen 10-year-old girl wanders into a world ruled by gods, witches, and spirits, and where humans are changed into beasts.",
                PictureSmall = pic,
                Actors       = new List <Actor>()
            };


            Actor act1 = new Actor
            {
                First  = "Daveigh",
                Middle = "",
                Last   = "Chase",
                Movies = new List <DVD>()
            };

            act1.Movies.Add(mov1);

            Actor act2 = new Actor
            {
                First  = "Suzanne",
                Middle = "",
                Last   = "Pleshette",
                Movies = new List <DVD>()
            };

            act2.Movies.Add(mov1);

            Actor act3 = new Actor
            {
                First  = "Miyu",
                Middle = "",
                Last   = "Irino",
                Movies = new List <DVD>()
            };

            act3.Movies.Add(mov1);



            Image im2 = Image.FromFile(@"C:\Users\Cleveland Codes\Pictures\images\003.gif");

            byte[] pic2 = ImageToByteArray(im2);

            DVD mov2 = new DVD
            {
                Title        = "City Lights",
                ReleaseDate  = new DateTime(1931, 10, 11),
                Price        = 2.59M,
                Genre        = "Comedy",
                Actor        = "Charles Chaplin, Virginia Cherrill, Florence Lee",
                Rating       = "G",
                Description  = "With the aid of a wealthy erratic tippler, a dewy-eyed tramp who has fallen in love with a sightless flower girl accumulates money to be able to help her medically.",
                PictureSmall = pic2,
                Actors       = new List <Actor>()
            };


            Actor act4 = new Actor
            {
                First  = "Charlie",
                Middle = "",
                Last   = "Chaplin",
                Movies = new List <DVD>()
            };

            act4.Movies.Add(mov2);

            Actor act5 = new Actor
            {
                First  = "Virginia",
                Middle = "",
                Last   = "Cherrill",
                Movies = new List <DVD>()
            };

            act5.Movies.Add(mov2);

            Actor act6 = new Actor
            {
                First  = "Florence",
                Middle = "",
                Last   = "Lee",
                Movies = new List <DVD>()
            };

            act6.Movies.Add(mov2);

            db.Actors.Add(act1);
            db.Actors.Add(act2);
            db.Actors.Add(act3);
            db.Actors.Add(act4);
            db.Actors.Add(act5);
            db.Actors.Add(act6);


            mov1.Actors.Add(act1);
            mov1.Actors.Add(act2);
            mov1.Actors.Add(act3);

            mov2.Actors.Add(act4);
            mov2.Actors.Add(act5);
            mov2.Actors.Add(act6);


            db.DVDs.Add(mov1);
            db.DVDs.Add(mov2);

            db.SaveChanges();
        }
        private static bool IsProductionYearSetCheck(DVD profile)
        {
            var result = profile.ProductionYear > 0;

            return(result);
        }
Ejemplo n.º 23
0
 public void Update(DVD dvd, int id)
 {
     _dvdRepository.Update(dvd);
 }
        private bool HasEvent(DVD profile)
        {
            var result = profile.EventList.HasEvent(EventType.ToString(), UserFirstName, UserLastName);

            return(result);
        }
Ejemplo n.º 25
0
 public IHttpActionResult Add(DVD dvd)
 {
     DVDRepo.Create(dvd);
     return(Created($"/dvd{dvd.MovieId}", dvd));
 }
        private static bool HasRating(DVD profile)
        {
            var result = !string.IsNullOrWhiteSpace(profile.Rating);

            return(result);
        }
Ejemplo n.º 27
0
 public HomeTheater(Screen screen, Projector projector, DVD dvd)
 {
     _screen    = screen;
     _projector = projector;
     _dvd       = dvd;
 }
        private bool IsRatingSystem(DVD profile)
        {
            var result = profile.RatingSystem.IsExpected(Value);

            return(result);
        }
Ejemplo n.º 29
0
 static void Main(string[] args)
 {
     IBorrowableDVD dvd = new DVD();
 }
Ejemplo n.º 30
0
        //                        0                    1                    2                     3                      4                       5                        6                              7                         8
        public void DoUpdate(string sConnectionString)
        {
            // get the set of books that we want to update
            TCore.Sql sql;

            SqlSelect sqls        = new SqlSelect(s_sBaseQuery, s_mpAliases);
            SqlWhere  swInnerJoin = new SqlWhere();

            swInnerJoin.Add("$$upc_dvd$$.ScanCode = $$upc_codes$$.ScanCode", SqlWhere.Op.And);
            sqls.AddInnerJoin(new SqlInnerJoin("$$#upc_codes$$", swInnerJoin));

            UpdateStatus flagsToUpdate = UpdateStatus.MediaType | UpdateStatus.Title | UpdateStatus.Categories | UpdateStatus.CoverSrc | UpdateStatus.Summary;

            if (m_config.ForceUpdateSummary)
            {
                flagsToUpdate |= UpdateStatus.Summary;
            }

            // we want to match any entry that hasn't tried to update ALL of our fields. (if they have tried some,
            // but not others, then try again. after all, we might know more fields now that we want to update.
            sqls.Where.Add($"$$upc_dvd$$.UpdateStatus & {(int)flagsToUpdate} <> {(int)flagsToUpdate}", SqlWhere.Op.And);
            sqls.Where.StartGroup(SqlWhere.Op.And);
            sqls.Where.Add(String.Format("$$upc_dvd$$.LastUpdate < '{0}'", DateTime.Now.ToString("d")), SqlWhere.Op.And);
            sqls.Where.Add("$$upc_dvd$$.LastUpdate IS NULL", SqlWhere.Op.Or);
            sqls.Where.EndGroup();

            // and lets update the latest scanned items first
            sqls.AddOrderBy("$$upc_codes$$.LastScanDate DESC");

            SR sr = Sql.OpenConnection(out sql, sConnectionString);

            if (!sr.Succeeded)
            {
                throw new Exception(sr.Reason);
            }

            // from this point on, we have to release the sql connection!!
            int cFailed = 0;

            try
            {
                sr = Sql.ExecuteQuery(sql, sqls.ToString(), this, null);

                if (!sr.Succeeded)
                {
                    throw new Exception(sr.Reason);
                }

                foreach (DvdElementEx dvdex in m_plDvd)
                {
                    string sError;

                    Console.WriteLine($"Trying to scrape dvd {dvdex.ScanCode}: {dvdex.Title}...");
                    DVD.ScrapeSet scrapedSet = 0;

                    if (m_config.ForceUpdateSummary)
                    {
                        dvdex.Summary = null;
                    }

                    if (DVD.FScrapeDvd(dvdex, out scrapedSet, out sError))
                    {
                        // we might not have scraped everything, but we scraped something...

                        if (scrapedSet.HasFlag(DVD.ScrapeSet.CoverSrc) && !DownloadCoverForDvd(dvdex, m_config.LocalCoverRoot, "covers", out sError))
                        {
                            Console.WriteLine($"FAILED: to download cover art: {sError}");
                            LogDvdUpdateError(dvdex, scrapedSet, sError);
                        }
                        else
                        {
                            Console.WriteLine(
                                $"SUCCEEDED: MediaType: {dvdex.MediaType}, Classification: {dvdex.Classification}");
                            AddDVDToUpdateQueue(dvdex, scrapedSet);
                        }
                    }
                    else
                    {
                        Console.WriteLine($"FAILED: {sError}");
                        LogDvdUpdateError(dvdex, scrapedSet, sError);
                        cFailed++;
                        if (cFailed > 150)
                        {
                            throw new Exception("giving up");
                        }
                    }
                }
            }
            finally
            {
                sql.Close();
            }
        }