Ejemplo n.º 1
0
        public ActionResult Add(User user, string birthdate, HttpPostedFileBase userimg)
        {
            if (Session["account"] != null)
            {
                if (_serviceUser.GetAll().FirstOrDefault(s => s.Email.ToUpper() == user.Email.ToUpper()) != null)
                    return RedirectToAction("Add");

                if (userimg != null)
                {
                    userimg.SaveAs(Server.MapPath("~/img/user/") + userimg.FileName);
                    user.ImagePath = "~/img/user/" + userimg.FileName;
                }

                user.Password = user.Password;
                user.BirthDate = Convert.ToDateTime(birthdate);
                user.Role = Role.User;
                _serviceUser.Insert(user);
                return RedirectToAction("Admin", "User");
            }
            else
                return RedirectToAction("Login", "User");
        }
Ejemplo n.º 2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Random rd = new Random();
            string[] types = { "Korku", "Macera", "Gerilim", "Drama", "Polisiye", "Romantik", "Komedi" };

            List<Film> LSTFilm = new List<Film>();
            for (int i = 0; i < 10; i++)
            {
                Film Newfilm = new Film();
                Newfilm.Name = FakeData.NameData.GetCompanyName();
                Newfilm.PublishDate = FakeData.DateTimeData.GetDatetime();
                Newfilm.ImdbPoint = FakeData.NumberData.GetNumber(1, 9);
                Newfilm.PosterImgPath = "../../images/r" + FakeData.TextData.GetNumeric(1) + ".jpg";
                Newfilm.Website = FakeData.NetworkData.GetDomain();

                List<FilmType> LSTFlmtyp = new List<FilmType>();
                for (int k = 0; k < 6; k++)
                {
                    FilmType newflmtyp = new FilmType();
                    newflmtyp.TypeName = types[k];
                    newflmtyp.Movies = LSTFilm;

                    LSTFlmtyp.Add(newflmtyp);
                    _serviceFilmType.Insert(newflmtyp);
                }
                Newfilm.FilmTypes = LSTFlmtyp;

                List<Actor> LSTActr = new List<Actor>();
                for (int k = 0; k < 5; k++)
                {
                    Actor act = new Actor();
                    act.Name = FakeData.NameData.GetFirstName();
                    act.Surname = FakeData.NameData.GetSurname();
                    act.BirthDate = FakeData.DateTimeData.GetDatetime();
                    act.ImagePath = "../../images/gridallbum" + FakeData.TextData.GetNumeric(1) + ".jpg";
                    act.Movies = LSTFilm;

                    LSTActr.Add(act);
                    _serviceActor.Insert(act);
                }
                Newfilm.Actors = LSTActr;

                List<Director> LSTDrt = new List<Director>();
                for (int m = 0; m < 5; m++)
                {
                    Director drt = new Director();
                    drt.Name = FakeData.NameData.GetFirstName();
                    drt.Surname = FakeData.NameData.GetSurname();
                    drt.BirthDate = FakeData.DateTimeData.GetDatetime();
                    drt.ImagePath = "../../images/gridallbum" + FakeData.TextData.GetNumeric(1) + ".jpg";
                    drt.Movies = LSTFilm;

                    LSTDrt.Add(drt);
                    _serviceDirector.Insert(drt);
                }
                Newfilm.Directors = LSTDrt;

                List<Writer> LSTWrt = new List<Writer>();
                for (int m = 0; m < 5; m++)
                {
                    Writer wrt = new Writer();
                    wrt.Name = FakeData.NameData.GetFirstName();
                    wrt.Surname = FakeData.NameData.GetSurname();
                    wrt.BirthDate = FakeData.DateTimeData.GetDatetime();
                    wrt.ImagePath = "../../images/gridallbum" + FakeData.TextData.GetNumeric(1) + ".jpg";
                    wrt.Movies = LSTFilm;

                    LSTWrt.Add(wrt);
                    _serviceWriter.Insert(wrt);
                }
                Newfilm.Writers = LSTWrt;

                List<Producer> LSTPrd = new List<Producer>();
                for (int m = 0; m < 5; m++)
                {
                    Producer prd = new Producer();
                    prd.ChairManName = FakeData.NameData.GetFullName();
                    prd.CompanyName = FakeData.NameData.GetCompanyName();
                    prd.FormDate = FakeData.DateTimeData.GetDatetime();
                    prd.CompanyAddress = FakeData.PlaceData.GetAddress();
                    prd.WebSite = FakeData.NetworkData.GetDomain();
                    prd.Movies = LSTFilm;

                    LSTPrd.Add(prd);
                    _serviceProducer.Insert(prd);
                }
                Newfilm.Producers = LSTPrd;

                LSTFilm.Add(Newfilm);
                _serviceFilm.Insert(Newfilm);
            }

            for (int i = 0; i < 5; i++)
            {
                User usr = new User();
                usr.Name = FakeData.NameData.GetFirstName();
                usr.Surname = FakeData.NameData.GetSurname();
                usr.BirthDate = FakeData.DateTimeData.GetDatetime();
                usr.Email = FakeData.NetworkData.GetEmail();
                usr.ImagePath = "../../images/gridallbum" + FakeData.TextData.GetNumeric(1) + ".jpg";
                usr.Password = "******";
                usr.Role = (ProjectTemplate.Core.Enums.Role)(rd.Next(0, 1));
                _serviceUser.Insert(usr);
            }

            MessageBox.Show("Veri Eklendi");
            dataGridView1.DataSource = _serviceFilm.GetAll();
        }
Ejemplo n.º 3
0
 public ActionResult Edit(User user)
 {
     if (Session["account"] != null)
     {
         if (ModelState.IsValid)
         {
             User updated = _serviceUser.GetById(user.Id);
             updated.Name = user.Name;
             updated.Surname = user.Surname;
             updated.Email = user.Email;
             _serviceUser.Update(updated);
         }
         return RedirectToAction("Admin", "User");
     }
     else
         return RedirectToAction("Login", "User");
 }