Ejemplo n.º 1
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
Ejemplo n.º 2
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                Roles.AddUserToRole(userprofile.UserName, Helpers.TEACHER_ROLE);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
Ejemplo n.º 3
0
        public ActionResult AddPhoto(int id = 0)
        {
            StudentPhotoViewModel vm = new StudentPhotoViewModel();

            var user = new UserProfile();
            if (id != 0)
            {
                user = db.UserProfiles.Find(id);
            }
            if (user == null)
            {
                return HttpNotFound();
            }
            vm.FullName = user.FullName;
            vm.UserId = user.UserId;
            return View(vm);
        }
Ejemplo n.º 4
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                userprofile.CreationDate = DateTime.Now;
                userprofile.FutureStudent = true;
                //Todo: currently requires two trips to db to autogenerate username.
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                userprofile.UserName = "******" + userprofile.UserId;
                db.Entry(userprofile).State = EntityState.Modified;
                db.SaveChanges();
                Roles.AddUserToRole(userprofile.UserName, Helpers.STUDENT_ROLE);
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
Ejemplo n.º 5
0
 public ActionResult Edit(UserProfile userprofile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userprofile).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(userprofile);
 }