Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,Chargenumber,Hours,Date")] Timecard timecard)
        {
            ViewBag.WeekStart = weekstart.ToString("yyyy-MM-dd");
            ViewBag.WeekEnd   = weekend.ToString("yyyy-MM-dd");

            var ChargeNumList = new List <string>();
            var ChargeNumQry  = from d in db.ChargeNumbers
                                orderby d.ID
                                select d.chargenumber;

            ChargeNumList.AddRange(ChargeNumQry.Distinct());
            ViewBag.ChargeNumList = new SelectList(ChargeNumList);

            List <string> datelist = new List <string>();

            for (int i = 0; i < 7; i++)
            {
                datelist.Add(weekstart.AddDays(i).ToString("yyyy-MM-dd"));
            }
            ViewBag.DateList = new SelectList(datelist);

            timecard.EmployeeName = User.Identity.Name;
            timecard.StartDate    = weekstart;
            timecard.EndDate      = weekend;
            timecard.SubmitDate   = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.Timecards.Add(timecard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(timecard));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                string key = movie.Title.Replace(" ", "");
                if (!ms.mClient.KeyExists(key))
                {
                    string value = movie.ReleaseDate + movie.Genre + movie.Price;
                    bool   ret   = ms.mClient.Set(key, value);
                    //string value2 = ms.mClient.Get(key) as string;
                    db.Movies.Add(movie);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.errmsg = movie.Title + " 同名电影已经存在,请改名";
                }
                // db.Movies.Add(movie);
                // db.SaveChanges();
                // return RedirectToAction("Index");
            }

            return(View(movie));
        }
Exemplo n.º 3
0
        public IHttpActionResult PutStudio(int id, Studio studio)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != studio.Id)
            {
                return(BadRequest());
            }

            db.Entry(studio).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
 public IActionResult CreateRating(RatingModel ratingmodel)
 {
     _dbContext.RatingModels.Add(ratingmodel);
     _dbContext.SaveChanges();
     ViewData["MovieID"] = new SelectList(_dbContext.MovieModels, "MovieID", "MovieName");
     return(View());
 }
Exemplo n.º 5
0
        private void objectListView1_ButtonClick(object sender, BrightIdeasSoftware.CellClickEventArgs e)
        {
            if (e.Column == actionsCol)
            {
                var selectedUser = (User)e.Item.RowObject;
                switch (selectedUser.StatusActionText)
                {
                case "Delete":
                    _db.Users.Remove(selectedUser);
                    _db.SaveChanges();
                    Users = _db.Users.ToList();
                    break;

                case "Approve":
                    var dbUser = _db.Users.Find(selectedUser.Id);
                    dbUser.UserStatus = UserStatus.FirstLogin;
                    _db.SaveChanges();
                    Users = _db.Users.ToList();
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Price,Rating,LogoFileName")] Movie movie, HttpPostedFileBase upload)
        {
            var toDb = false;

            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (toDb)
                    {
                        // Store image into database
                        var avatarFileContent = FileUpload.StoreIntoDatabase(upload);
                        movie.Files = new List <File> {
                            avatarFileContent
                        };
                    }
                    else
                    {
                        // Store image on disk
                        var avatarFilePath = FileUpload.StoreOnServer(upload);
                        movie.FilePaths = new List <FilePath> {
                            avatarFilePath
                        };
                    }
                }

                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 7
0
        public ActionResult AddToMyMovies(int id, string returnUrl)
        {
            Movie movie = db.Movies.Find(id);

            var userid = User.Identity.GetUserId();
            var m      = movie.AddedToMyMovies + userid;

            movie.AddedToMyMovies = m;

            ;


            var myMovie = new MyMovie
            {
                Genres      = movie.Genres,
                IdImdb      = movie.IdImdb,
                ImdbRating  = movie.ImdbRating,
                ReleaseYear = movie.ReleaseYear,
                Title       = movie.Title,
                Votes       = movie.Votes,
                Note        = "",
                Watched     = "no",
                UserID      = User.Identity.GetUserId(),
                MyRating    = ""
            };

            db.MyMovies.Add(myMovie);
            db.SaveChanges();


            return(Redirect(returnUrl));
        }
Exemplo n.º 8
0
        public IActionResult AddToFavorites(int id, string routedQuery)
        {
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;
            var claim          = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier);
            var userId         = claim.Value;
            var favorites      = _movieContext.Favorites.Where(x => x.UserId == userId).ToList();

            Favorites favorite = new Favorites()
            {
                UserId  = userId,
                MovieId = id
            };

            if (ModelState.IsValid)
            {
                _movieContext.Favorites.Add(favorite);
                _movieContext.SaveChanges();

                return(RedirectToAction("Result", new { query = routedQuery }));
            }
            else
            {
                TempData["Error"] = "Could not add to favorites list.";
                return(RedirectToAction("Result"));
            }
        }
Exemplo n.º 9
0
        public ActionResult SendMovies(IQueryable <Movie> movies, TMDbLib.Objects.Movies.Movie movie, TMDbClient client)
        {
            int id;

            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

            for (id = 0; id <= 30; id++)
            {
                try
                {
                    movie = client.GetMovieAsync(id).Result;
                }

                catch (NullReferenceException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

                if (movie != null)
                {
                    if (movie.Adult == false)
                    {
                        Movie objMovie = movies.FirstOrDefault(x => x.RemoteId.Equals(movie.Id));
                        if (objMovie != null) //achei no banco local
                        {
                            objMovie.Original_title    = movie.OriginalTitle;
                            objMovie.Release_date      = movie.ReleaseDate;
                            objMovie.Original_Language = new CultureInfo(movie.OriginalLanguage).DisplayName;
                            objMovie.Description       = movie.Overview;
                            objMovie.Budget            = movie.Budget;
                            objMovie.Vote_average      = movie.VoteAverage;
                        }
                        else //não achei esse movie no banco local
                        {
                            objMovie = new Movie
                            {
                                RemoteId          = movie.Id,
                                Original_title    = movie.OriginalTitle,
                                Release_date      = movie.ReleaseDate,
                                Description       = movie.Overview,
                                Original_Language = new CultureInfo(movie.OriginalLanguage).DisplayName,
                                Budget            = movie.Budget,
                                Vote_average      = movie.VoteAverage
                            };

                            //depois de atribuir tudo
                            db.Movies.Add(objMovie);
                            db.SaveChanges();
                        }
                    }
                }
            }
            return(View(movies));
        }
Exemplo n.º 10
0
 public ActionResult Create(Movie m)
 {
     if (ModelState.IsValid)
     {
         db.Movies.Add(m);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(m));
 }
Exemplo n.º 11
0
        public IActionResult Entry(Movie movie = null, string type = "", int movieId = -1)
        {
            //this only takes us the success screen if the information is entered correctly. this protects from people using something like postman to enter in values we don't want
            if (type == "remove")
            {
                movie = _context.Movies.FirstOrDefault(m => m.MovieID == movieId);
                if (movie != null)
                {
                    _context.Remove(movie);
                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
                else
                {
                    return(View("Error"));
                }
            }
            else if (!ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                Movie searchedMovie = _context.Movies.FirstOrDefault(m => m.MovieID == movieId);
                if (searchedMovie != null)
                {
                    //the movie already exists so it's an edit
                    //_context.Remove(searchedMovie);
                    //_context.SaveChanges();

                    //_context.Movies.Add(movie);

                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Rating   = movie.Rating;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Director = movie.Director;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Edited   = movie.Edited;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Year     = movie.Year;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Title    = movie.Title;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).LentTo   = movie.LentTo;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Notes    = movie.Notes;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Category = movie.Category;

                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
                else
                {
                    //commenting out old way
                    //Storage.AddMovie(movie);
                    //the movie is a n
                    _context.Movies.Add(movie);
                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
            }
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "ID,CustomerName,Email,Residence,SalesPerson,ItemBought,MonthBought,Price,Qty,Sales")]  excel excel)
        {
            if (ModelState.IsValid)
            {
                db.excel.Add(excel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(excel));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "ID,Email,Name,Position,MailAddress,SSN,Deduction,Phone,HourRate,Salary,CommisonRate,HourLimit,PaymentMethod,Vacation")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = employee.ID }));
            }

            return(View(employee));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "ID_SPOTKANIA,ID_DRUZYNY,ID_MIASTA,DRU_ID_DRUZYNY,BRAMKI_D1,BRAMKI_D2,DATA_SPOTKANIA")] Spotkania spotkania)
        {
            if (ModelState.IsValid)
            {
                db.SPOTKANIA.Add(spotkania);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(spotkania));
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "ID_DRUZYNY,ID_MIASTA,NAZWA_DRUZYNY,PUNKTY,BRAMKI,ILOSC_SPOTKAN")] Druzyny druzyny)
        {
            if (ModelState.IsValid)
            {
                db.DRUZYNY.Add(druzyny);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(druzyny));
        }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Include = "ID,RatingName,LastModified,LastModifiedBy")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                db.Ratings.Add(rating);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rating));
        }
Exemplo n.º 17
0
        public ActionResult Create([Bind(Include = "ClientId,FirstName,LastName,Address,City,State,Zip,Phone,DoB,Email")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "Id,Title,ReleaseDate,Price,Rating,TmdbId,VoteCount,VoteAverage,Overview,PosterPath")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 19
0
        public ActionResult Create([Bind(Include = "ID,OwnerID,Title,Genre,Year,Length,Format,OnLoan,LoanedToID,LoanedDate")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index", "Collection"));
            }

            return(View(movie));
        }
Exemplo n.º 20
0
        public ActionResult Create([Bind(Include = "id,name,img,pubdate,desc")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "ID,Title,Stocks,Description,ReleaseDate")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 22
0
 public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Rating,Description,Picture,Video")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Movies.Add(movie);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MoviesGenre = MoviesGenre.get();
     return(View(movie));
 }
Exemplo n.º 23
0
        public ActionResult Create([Bind(Include = "ID,CreatedBy,EquipmentName,ReleaseDate,TypeofAssets,Barcode,Location,RoomName")] excel excel)
        {
            if (ModelState.IsValid)
            {
                db.excel.Add(excel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(excel));
        }
Exemplo n.º 24
0
        public ActionResult Create([Bind(Include = "ID,Name,ReleaseDate,Location,Barcode,Type,CreatedBy,roomName")] Asset asset)
        {
            if (ModelState.IsValid)
            {
                db.Assets.Add(asset);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(asset));
        }
        public ActionResult Create([Bind(Include = "ID,EmployeeName,Salary,PayDate")] PayRoll payRoll)
        {
            if (ModelState.IsValid)
            {
                db.PayRolls.Add(payRoll);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(payRoll));
        }
Exemplo n.º 26
0
        public ActionResult Create([Bind(Include = "ID_PILKARZA,ID_DRUZYNY,IMIE_PILKARZA,NAZWISKO_PILKARZA,WIEK_PILKARZA,POZYCJA,NARODOWOSC_PILKARZA")] Pilkarze pilkarze)
        {
            if (ModelState.IsValid)
            {
                db.PILKARZE.Add(pilkarze);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pilkarze));
        }
Exemplo n.º 27
0
        public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Price,Rating")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 28
0
        public ActionResult Create(Car car)
        {
            if (ModelState.IsValid)
            {
                db.Cars.Add(car);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
        public ActionResult Create([Bind(Include = "ID_SEDZI,IMIE_SEDZI,NAZWISKO_SEDZI")] Sedziowie sedziowie)
        {
            if (ModelState.IsValid)
            {
                db.SEDZIOWIE.Add(sedziowie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sedziowie));
        }
Exemplo n.º 30
0
        public ActionResult Create([Bind(Include = "ID_SPOTKANIA,ID_DRUZYNY,ID_PILKARZA,MINUTA_WYNIKU")] Wynik wynik)
        {
            if (ModelState.IsValid)
            {
                db.WYNIK.Add(wynik);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(wynik));
        }
 public void AlterTableTest()
 {
   ReInitDb();
   MovieDBContext db = new MovieDBContext();      
   db.Database.Initialize(true);
   var l = db.MovieFormats.ToList();
   foreach (var i in l)
   {
   }
   MovieFormat m = new MovieFormat();
   m.Format = 8.0f;
   db.MovieFormats.Add(m);
   db.SaveChanges();
 }
Exemplo n.º 32
0
        public void AddingEmptyRow()
        {
            using (MovieDBContext ctx = new MovieDBContext())
              {
            ctx.Database.Initialize(true);
            ctx.EntitySingleColumns.Add(new EntitySingleColumn());
            ctx.SaveChanges();
              }

              using (MovieDBContext ctx2 = new MovieDBContext())
              {
            var q = from esc in ctx2.EntitySingleColumns where esc.Id == 1 select esc;
            Assert.AreEqual(1, q.Count());
              }
        }
Exemplo n.º 33
0
        public void ConcurrencyCheck()
        {
            using (MovieDBContext db = new MovieDBContext())
              {
            db.Database.ExecuteSqlCommand(
            @"DROP TABLE IF EXISTS `test3`.`MovieReleases`");

            db.Database.ExecuteSqlCommand(
            @"CREATE TABLE `MovieReleases` (
              `Id` int(11) NOT NULL,
              `Name` varbinary(45) NOT NULL,
              `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
              PRIMARY KEY (`Id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=binary");
            MySqlTrace.Listeners.Clear();
            MySqlTrace.Switch.Level = SourceLevels.All;
            GenericListener listener = new GenericListener();
            MySqlTrace.Listeners.Add(listener);
            try
            {
              MovieRelease mr = db.MovieReleases.Create();
              mr.Id = 1;
              mr.Name = "Commercial";
              db.MovieReleases.Add(mr);
              db.SaveChanges();
              mr.Name = "Director's Cut";
              db.SaveChanges();
            }
            finally
            {
              db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases`");
            }
            // Check sql
            Regex rx = new Regex(@"Query Opened: (?<item>UPDATE .*)", RegexOptions.Compiled | RegexOptions.Singleline);
            foreach (string s in listener.Strings)
            {
              Match m = rx.Match(s);
              if (m.Success)
              {
            CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelect);
            Assert.Pass();
              }
            }
            Assert.Fail();
              }
        }