예제 #1
0
        public ActionResult Create([Bind(Include = "ID,Name,Id_name")] CS_Departments cS_Departments)
        {
            if (ModelState.IsValid)
            {
                db.CS_Departments.Add(cS_Departments);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cS_Departments));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "ID,Title,Content,Lecturer_id")] Publication publication)
        {
            if (ModelState.IsValid)
            {
                db.Publications.Add(publication);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Lecturer_id = new SelectList(db.Lecturers, "ID", "Name", publication.Lecturer_id);
            return(View(publication));
        }
예제 #3
0
        public ActionResult Create(string Title, string Content, int Created_by, HttpPostedFileBase file)
        {
            string alternativePath = @"/Content/images/" + file.FileName;

            file.SaveAs(Path.Combine(Server.MapPath("~/Content/images"), file.FileName));
            var news = NewsService.SetNews(Title, Content, Created_by, alternativePath);

            news.Created_at = DateTime.Now;
            news.Updated_at = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(news));
        }
예제 #4
0
        public ActionResult Create(string Name, string Lastname, string Phone, string Email, string About, string Additional_info, string Full_address, HttpPostedFileBase file)
        {
            string alternativePath = @"/Content/images/" + file.FileName;
            var    photo           = LecturersService.SetPhoto(alternativePath);

            file.SaveAs(Path.Combine(Server.MapPath("~/Content/images"), file.FileName));
            if (photo != null)
            {
                db.Photos.Add(photo);
                db.SaveChanges();
            }

            var lecturer = LecturersService.SetLecturer(Name, Lastname, Phone, Email, About, Additional_info, photo.ID, Full_address);

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

            ViewBag.Photo_id = new SelectList(db.Photos, "ID", "Image_path", lecturer.Photo_id);
            return(View(lecturer));
        }
예제 #5
0
        public ActionResult Create(HttpPostedFileBase file)
        {
            Photo photo = new Photo();

            photo.Created_at = DateTime.Now;
            photo.Image_path = Path.Combine(Server.MapPath("~/Content/images"), file.FileName);
            file.SaveAs(photo.Image_path);
            if (ModelState.IsValid)
            {
                db.Photos.Add(photo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public ActionResult Registration(string firstname, string lastname, string username, string email, string pass)
        {
            bool emailExists = UserService.EmailExists(email);

            if (!emailExists)
            {
                var user = UserService.SetUser(firstname, lastname, username, email, UserService.Hash(pass));
                using (TsuModel db = new TsuModel())
                {
                    db.Users.Add(user);
                    db.SaveChanges();
                    return(View("RegistrationSuccessful"));
                }
            }

            return(View());
        }