Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,fullname,username,email,password,usertype")] users users, HttpPostedFileBase std_trans)
        {
            if (ModelState.IsValid)
            {
                var    fileName = Path.GetFileName(std_trans.FileName);
                string path     = Path.Combine(Server.MapPath("~/Uploads"), fileName);
                std_trans.SaveAs(path);
                string std_trans2 = fileName;

                teamleaders teams = new teamleaders {
                    std_gpa    = double.Parse(Request["std_gpa"]),
                    std_skills = Request["std_skills"],
                    std_level  = Request["std_level"],
                    std_trans  = std_trans2,
                    user_id    = users.Id
                };


                db.teamleaders.Add(teams);
                db.users.Add(users);
                db.SaveChanges();

                //ViewBag.pgname = "project";
                return(RedirectToAction("Login"));
            }

            return(View(users));
        }
        public ActionResult Index(users user, string std_level, string std_skills, float std_gpa, HttpPostedFileBase file)
        {
            var username = db.users.Where(x => x.username == user.username).ToList();

            if (ModelState.IsValid)
            {
                if (username.Count() == 0)
                {
                    /* string std_trans*/
                    teamleaders leader = new teamleaders();
                    leader.std_level  = std_level;
                    leader.std_skills = std_skills;
                    leader.std_gpa    = std_gpa;
                    // leader.std_trans = std_trans;
                    string fileName = Path.GetFileName(file.FileName);
                    var    path     = Path.Combine(Server.MapPath("~/Uploads"), fileName);
                    file.SaveAs(path);
                    string std_trans2 = fileName;
                    leader.std_trans = std_trans2;
                    user.usertype    = 2;
                    db.users.Add(user);
                    leader.user_id = user.Id;
                    db.teamleaders.Add(leader);
                    db.SaveChanges();
                    return(RedirectToAction("Login", "users"));
                }
            }
            return(View());
        }