public IActionResult Add(PersonVM model, int[] jobs)
        {
            if (ModelState.IsValid)
            {
                Person person = new Person();
                person.Name      = model.name;
                person.SurName   = model.surname;
                person.BirthDate = model.birthdate;
                person.Country   = model.country;

                _context.People.Add(person);
                _context.SaveChanges();

                int PersonID = person.ID;

                foreach (var item in jobs)
                {
                    PersonJob personJob = new PersonJob();
                    personJob.PersonID = PersonID;
                    personJob.JobID    = item;

                    _context.PersonJobs.Add(personJob);
                }
                _context.SaveChanges();

                return(Redirect("/Admin/Person/Index"));
            }
            else
            {
                return(View(getJobs()));
            }
        }
 public int AddItem(Login item)
 {
     //using (IMDBContext _db = new IMDBContext())
     //{
     _db.Login.Add(item);
     return(_db.SaveChanges());
     //}
 }
        public IActionResult Delete(int id)
        {
            AdminUser adminUser = _context.AdminUsers.FirstOrDefault(q => q.ID == id);

            adminUser.IsDeleted = true;
            _context.SaveChanges();

            return(Json("Silme işlemi başarılı!!"));
        }
 public int AddItem(Actor item)
 {
     //using (IMDBContext _db = new IMDBContext())
     {
         _db.Actor.Add(item);
         _etkilenenSatir = _db.SaveChanges();
         return(_etkilenenSatir);
     }
 }
Beispiel #5
0
        public int AddItem(Film item)
        {
            //using (IMDBContext _db = new IMDBContext())
            {
                _db.Film.Add(item);

                _affectedrow = _db.SaveChanges();

                return(_affectedrow);
            }
        }
        public ActionResult Create([Bind(Include = "MovieId,Name,Yor,Poster")] Movie movie, int ProducerId, string [] SelectedActorIds)
        {
            var idforimagename = 1;  //Image name is same as Movie Id like 1.jpg , 2.jpg etc

            try
            {
                try
                {
                    //Approch 3
                    var lst = db.Movies;
                    if (lst.Any())
                    {
                        idforimagename = lst.Max(t => t.MovieId);
                        idforimagename++;
                    }
                }
                catch (Exception e) { }
                var poster = Request.Files["Poster"];
                if (poster.ContentLength >= 1048576)
                {
                    ViewBag.BrochureError = "Error : Image size should not exceed 1MB !";
                    return(View(movie));
                }
                var str = poster.FileName.Substring(poster.FileName.LastIndexOf('.'));
                //This line is important , verify it saved the image to respetive directorty or not
                poster.SaveAs(Server.MapPath("~/") + @"Images/Movies/" + idforimagename + str);
                movie.Poster     = "../../Images/Movies/" + idforimagename + str;
                movie.ProducerId = ProducerId; // or movie.producer=producer
            }
            catch (Exception e)
            {
            }

            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();                         //After Movie is saved , Now Fill the table ActorMovie

                int        mvid          = movie.MovieId; //Get the Id of latest saved movie so that you can associate it with Actor (AcotrId , MovieId)
                List <int> selectedactor = new List <int>();

                foreach (var sc in SelectedActorIds)
                {
                    selectedactor.Add(Int32.Parse(sc));
                }

                AddSeletedActors(selectedactor.ToArray(), movie.MovieId);

                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
        public int AddItem(Rating item)
        {
            //using (IMDBContext _db = new IMDBContext())
            //{
            _db.Rating.Add(item);

            _affectedrow = _db.SaveChanges();

            return(_affectedrow);


            //}
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "MovieId,Name,Yor,Poster")] Movie movie, int ProducerId, string [] SelectedActorIds)
        {
            var idforimagename = 1;

            try
            {
                try
                {
                    var lst = db.Movies;
                    if (lst.Any())
                    {
                        idforimagename = lst.Max(t => t.MovieId);
                        idforimagename++;
                    }
                }
                catch (Exception e) { }
                var poster = Request.Files["Poster"];
                if (poster.ContentLength >= 1048576)
                {
                    ViewBag.BrochureError = "Error : Image size should not exceed 1MB !";
                    return(View(movie));
                }
                var str = poster.FileName.Substring(poster.FileName.LastIndexOf('.'));
                poster.SaveAs(Server.MapPath("~/") + @"Images/Movies/" + idforimagename + str);
                movie.Poster     = "../../Images/Movies/" + idforimagename + str;
                movie.ProducerId = ProducerId;
            }
            catch (Exception e)
            {
            }

            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();

                int        mvid          = movie.MovieId;
                List <int> selectedactor = new List <int>();

                foreach (var sc in SelectedActorIds)
                {
                    selectedactor.Add(Int32.Parse(sc));
                }

                AddSeletedActors(selectedactor.ToArray(), movie.MovieId);

                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
        public IActionResult Add(RateVM model)
        {
            int id       = model.movieid;
            int userID   = Convert.ToInt32(TempData["ID"]);
            var oldRates = _context.Rates.Where(q => q.MovieID == id && q.UserID == userID).ToList();


            Rate rate = new Rate();

            rate.MovieID = id;
            rate.Point   = model.point;
            rate.UserID  = userID;

            Movie  movie     = _context.Movies.Include(q => q.Rates.Where(q => q.IsDeleted == false)).FirstOrDefault(q => q.ID == id);
            var    name      = movie.Name;
            double totalrate = movie.TotalRate;

            if (oldRates.Count() != 0)
            {
                totalrate = movie.TotalRate - oldRates[0].Point;
            }

            totalrate += model.point;

            foreach (var item in oldRates)
            {
                //item.IsDeleted = true;
                _context.Rates.Remove(item);
            }
            movie.TotalRate = totalrate;
            _context.Rates.Add(rate);
            _context.SaveChanges();



            double rated    = movie.Rates.Where(q => q.IsDeleted == false).Count();
            double awrpoint = totalrate / rated;
            double awerate  = Math.Round(awrpoint, 1, MidpointRounding.AwayFromZero);

            movie.AvrPoint = awerate;
            _context.SaveChanges();



            string url = "/movie/" + id + "/" + UrlHelper.FriendlyUrl(name);

            return(Redirect(url));
        }
Beispiel #10
0
        public IActionResult Add(GenreVM model)
        {
            if (ModelState.IsValid)
            {
                Genre genre = new Genre();
                genre.Name = model.name;

                _context.Genres.Add(genre);
                _context.SaveChanges();
                return(RedirectToAction("Index", "Genre"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #11
0
        public IActionResult Add(WatchlistVM model)
        {
            WatchList watchList = new WatchList();

            watchList.MovieID = model.movieid;
            watchList.UserID  = Convert.ToInt32(TempData["ID"]);

            UserPageVM user = new UserPageVM();

            user.UserWatch = _context.WatchLists.Include(x => x.Movie).Where(q => q.UserID == Convert.ToInt32(TempData["ID"])).ToList().ToPagedList();

            int counter = 0;

            foreach (var item in user.UserWatch)
            {
                if (model.movieid == item.MovieID)
                {
                    counter++;
                }
            }


            if (counter == 0)
            {
                _context.WatchLists.Add(watchList);
                _context.SaveChanges();

                return(Redirect("/watchlist"));
            }

            return(Redirect("/watchlist"));
        }
Beispiel #12
0
 public static void DeleteFilm(int id)
 {
     using (IMDBContext db = new IMDBContext())
     {
         db.Film.Remove(db.Film.Find(id));
         db.SaveChanges();
     }
 }
 public static void AddDirector(Director _director)
 {
     using (IMDBContext db = new IMDBContext())
     {
         db.Director.Add(_director);
         db.SaveChanges();
     }
 }
Beispiel #14
0
 public static void AddType(Entity.Model.Type _type)
 {
     using (IMDBContext db = new IMDBContext())
     {
         db.Type.Add(_type);
         db.SaveChanges();
     }
 }
 public static void DeleteDirector(int id)
 {
     using (IMDBContext db = new IMDBContext())
     {
         db.Director.Remove(db.Director.Find(id));
         db.SaveChanges();
     }
 }
 public static void UpdateDirector(Director _director)
 {
     using (IMDBContext db = new IMDBContext())
     {
         var result = db.Director.Find(_director.DirectorID);
         result.DirectorName = _director.DirectorName;
         db.SaveChanges();
     }
 }
        public IActionResult Delete(int id)
        {
            Comment person = _context.Comments.FirstOrDefault(q => q.ID == id);

            person.IsDeleted = true;
            _context.SaveChanges();

            return(Json("Silme işlemi başarılı!!"));
        }
Beispiel #18
0
 public static void GiveVote(int id, double point)
 {
     using (IMDBContext db = new IMDBContext())
     {
         var result = db.Film.Find(id);
         result.PointCount += 1;
         result.Point       = ((result.Point * (result.PointCount - 1)) + point) / (result.PointCount);
         db.SaveChanges();
     }
 }
Beispiel #19
0
        public IActionResult Add(CommentVM model)
        {
            Comment comment = new Comment();

            comment.Content = model.content;
            comment.UserID  = Convert.ToInt32(TempData["ID"]);
            comment.MovieID = model.movieid;
            comment.Header  = model.header;

            int   id    = model.movieid;
            Movie movie = _context.Movies.Include(q => q.Comments.Where(q => q.IsDeleted == false)).FirstOrDefault(q => q.ID == id);
            var   name  = movie.Name;


            _context.Comments.Add(comment);
            _context.SaveChanges();

            string url = "/movie/" + id + "/" + UrlHelper.FriendlyUrl(name);

            return(Redirect(url));
        }
        public IActionResult Register(UserRegisterVM model)
        {
            if (ModelState.IsValid)
            {
                User user = new User();
                user.UserName = model.username;
                user.EMail    = model.email;
                user.Password = model.password;
                _context.Users.Add(user);
                _context.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            else
            {
                TempData["error2"] = "Passwords do not match!";


                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #21
0
 public static void UpdateFilm(Film _film)
 {
     using (IMDBContext db = new IMDBContext())
     {
         var result = db.Film.Find(_film.FilmID);
         result.Description = _film.Description;
         result.DirectorID  = _film.DirectorID;
         result.FilmName    = _film.FilmName;
         result.TypeID      = _film.TypeID;
         db.SaveChanges();
     }
 }
Beispiel #22
0
 public static void AddFilm(Film _film)
 {
     using (IMDBContext db = new IMDBContext())
     {
         db.Film.Add(_film);
         try
         {
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             //Exception - Tarih seçilmedi!
         }
     }
 }
Beispiel #23
0
        public static void AddUserInC6(IManUser manager)
        {
            using (var db = new IMDBContext())
            {
                db.CUSTOM6.Add(new CUSTOM6
                {
                    CUSTOM_ALIAS = manager.Custom1,
                    C_DESCRIPT = manager.FullName,
                    EDITWHEN = KConfig.GetKDateTimeUTC,
                    ENABLED = "Y",
                    IS_HIPAA = "N"
                });

                db.SaveChanges();
            }
        }
Beispiel #24
0
        public static void AddEngInC2(string num, string engDescription, string clientId)
        {
            using (var db = new IMDBContext())
            {
                db.CUSTOM2.Add(new CUSTOM2
                {
                    CPARENT_ALIAS = clientId,
                    CUSTOM_ALIAS = num,
                    C_DESCRIPT = engDescription,
                    EDITWHEN = KConfig.GetKDateTimeUTC,
                    ENABLED = "Y",
                    IS_HIPAA = "N"
                });

                db.SaveChanges();
            }
        }
        public async Task <IActionResult> Index(UserLoginVM model)
        {
            if (ModelState.IsValid)
            {
                User user = _context.Users.FirstOrDefault(x => x.UserName == model.username && x.Password == model.password);

                if (user != null)
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Name, model.username),
                        new Claim(ClaimTypes.UserData, "User"),
                        new Claim(ClaimTypes.Sid, user.ID.ToString())
                    };

                    var userIdentity = new ClaimsIdentity(claims, "login");

                    ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity);

                    await HttpContext.SignInAsync(principal);

                    user.LastLoginDate = DateTime.Now;

                    _context.SaveChanges();


                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["error"] = "Username or password wrong!";

                    return(RedirectToAction("Index", "Home"));
                    //return Redirect("/Site/Home/Index/" + model);
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult AddNewActor(String name, String sex, String dob, String bio)
        {
            Actor actor = new Actor();

            actor.Name = name;
            actor.Sex  = sex;
            actor.DOB  = Convert.ToDateTime(dob);
            actor.Bio  = bio;

            try
            {
                using (IMDBContext db = new IMDBContext())
                {
                    db.Actors.Add(actor);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
            }
            return(Json(new { Success = true }));
        }
        public async Task <IActionResult> Index(LoginVM model)
        {
            if (ModelState.IsValid)
            {
                AdminUser adminuser = _context.AdminUsers.FirstOrDefault(x => x.EMail == model.EMail && x.Password == model.Password);

                if (adminuser != null)
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Name, model.EMail),
                        new Claim(ClaimTypes.Role, adminuser.Roles),
                        new Claim(ClaimTypes.UserData, "Admin")
                    };

                    var userIdentity = new ClaimsIdentity(claims, "login");

                    ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity);

                    await HttpContext.SignInAsync(principal);

                    adminuser.LastLoginDate = DateTime.Now;

                    _context.SaveChanges();

                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    ViewBag.error = "Email or password wrong!";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
        public IActionResult Add(MovieVM model, int[] genres, int[] directorarray, int[] scenaristarray, int[] stararray)
        {
            string imagepath = "";

            if (model.movieposter != null)
            {
                var guid = Guid.NewGuid().ToString();
                var path = Path.Combine(
                    Directory.GetCurrentDirectory(),
                    "wwwroot/adminsite/movieposter", guid + ".jpg");
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    model.movieposter.CopyTo(stream);
                }
                imagepath = guid + ".jpg";
            }

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

            string imgpaths = "";

            if (model.movieImages != null)
            {
                foreach (var item in model.movieImages)
                {
                    var guid = Guid.NewGuid().ToString();

                    var path = Path.Combine(
                        Directory.GetCurrentDirectory(),
                        "wwwroot/adminsite/movieimages", guid + ".jpg");
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        item.CopyTo(stream);
                    }

                    imgpaths = guid + ".jpg";
                    paths.Add(imgpaths);
                }
            }

            model.imagepaths = paths;


            if (ModelState.IsValid)
            {
                Movie movie = new Movie();
                movie.Name        = model.name;
                movie.Duration    = model.duration;
                movie.ReleaseDate = model.releasedate;
                movie.PosterURL   = imagepath;
                movie.Description = model.description;

                _context.Movies.Add(movie);
                _context.SaveChanges();

                int MovieID = movie.ID;

                foreach (var item in genres)
                {
                    MovieGenre movieGenre = new MovieGenre();
                    movieGenre.MovieID = MovieID;
                    movieGenre.GenreID = item;

                    _context.MovieGenres.Add(movieGenre);
                }
                foreach (var item in directorarray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 1;

                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in scenaristarray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 2;
                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in stararray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 3;
                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in model.imagepaths)
                {
                    MovieImages image = new MovieImages();
                    image.ImagePath = item;
                    image.MovieID   = MovieID;

                    _context.MovieImages.Add(image);
                }
                _context.SaveChanges();

                //return RedirectToAction("Index", "Movie");
                return(Redirect("/Admin/Movie/Index"));
            }
            else
            {
                return(View(getGenresJob()));
            }
        }
Beispiel #29
0
 void IRepository <T> .Save()
 {
     context.SaveChanges();
 }
Beispiel #30
0
 public void SaveChanges()
 {
     _context.SaveChanges();
 }
Beispiel #31
0
        public static void SetCOMINDEXtoY(double num)
        {
            using (var db = new IMDBContext())
            {
                var original = db.DOCMASTERs.Find(num, 1 );

                original.COMINDEX = "Y";

                db.SaveChanges();
            }
        }
 public void Save()
 {
     _imdbContext.SaveChanges();
 }