public ActionResult AddImage(HttpPostedFileBase image1)
        {
            String user   = User.Identity.GetUserId();
            var    latest = (from p in db.CppUsers
                             where
                             p.AspNetUserId == user
                             select new
            {
                p.Id
            }).First();
            //Current User's ID
            var id = latest.Id;
            // load profile
            Profile p1 = db.Profiles.Where(b => b.CppUserId == id).ToList().FirstOrDefault();

            // if not image exist load image into profile
            if (image1 != null)
            {
                p1.Photo = new byte[image1.ContentLength];
                image1.InputStream.Read(p1.Photo, 0, image1.ContentLength);
            }
            db.Entry(p1).State = EntityState.Modified;
            db.SaveChanges();
            return(View(p1));
        }
Esempio n. 2
0
        public ActionResult Edit([Bind(Include = "Id,CppUserId,Sunday0,Sunday1,Sunday2,Sunday3,Sunday4,Sunday5,Sunday6,Sunday7,Sunday8,Sunday9,Sunday10,Sunday11,Sunday12,Sunday13,Sunday14,Sunday15,Sunday16,Sunday17,Sunday18,Sunday19,Sunday20,Sunday21,Sunday22,Sunday23,Mon0,Mon1,Mon2,Mon3,Mon4,Mon5,Mon6,Mon7,Mon8,Mon9,Mon10,Mon11,Mon12,Mon13,Mon14,Mon15,Mon16,Mon17,Mon18,Mon19,Mon20,Mon21,Mon22,Mon23,Tue0,Tue1,Tue2,Tue3,Tue4,Tue5,Tue6,Tue7,Tue8,Tue9,Tue10,Tue11,Tue12,Tue13,Tue14,Tue15,Tue16,Tue17,Tue18,Tue19,Tue20,Tue21,Tue22,Tue23,Wed0,Wed1,Wed2,Wed3,Wed4,Wed5,Wed6,Wed7,Wed8,Wed9,Wed10,Wed11,Wed12,Wed13,Wed14,Wed15,Wed16,Wed17,Wed18,Wed19,Wed20,Wed21,Wed22,Wed23,Thu0,Thu1,Thu2,Thu3,Thu4,Thu5,Thu6,Thu7,Thu8,Thu9,Thu10,Thu11,Thu12,Thu13,Thu14,Thu15,Thu16,Thu17,Thu18,Thu19,Thu20,Thu21,Thu22,Thu23,Fri0,Fri1,Fri2,Fri3,Fri4,Fri5,Fri6,Fri7,Fri8,Fri9,Fri10,Fri11,Fri12,Fri13,Fri14,Fri15,Fri16,Fri17,Fri18,Fri19,Fri20,Fri21,Fri22,Fri23,Sat0,Sat1,Sat2,Sat3,Sat4,Sat5,Sat6,Sat7,Sat8,Sat9,Sat10,Sat11,Sat12,Sat13,Sat14,Sat15,Sat16,Sat17,Sat18,Sat19,Sat20,Sat21,Sat22,Sat23")] AvailabilitySchedule availabilitySchedule)
        {
            if (ModelState.IsValid)
            {
                String user   = User.Identity.GetUserId();
                var    latest = (from p in db.CppUsers
                                 where
                                 p.AspNetUserId == user
                                 select new
                {
                    p.Id
                }).First();

                //Current User's ID
                var id = latest.Id;

                availabilitySchedule.CppUserId = id;


                //var result = db.AvailabilitySchedules.Where(a => a.CppUserId == id).First();
                //int theid = Int32.Parse(result.Id.ToString());
                //availabilitySchedule.Id = theid;
                db.Entry(availabilitySchedule).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CppUserId = new SelectList(db.CppUsers, "Id", "AspNetUserId", availabilitySchedule.CppUserId);
            return(View(availabilitySchedule));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] AspNetUser aspNetUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspNetUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aspNetUser));
 }
 public ActionResult Edit([Bind(Include = "Id,Description")] ViolationType violationType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(violationType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(violationType));
 }
 public ActionResult Edit([Bind(Include = "Id,ContactListOwnerId,ContactListMemberId")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ContactListOwnerId = new SelectList(db.CppUsers, "Id", "AspNetUserId", contact.ContactListOwnerId);
     return(View(contact));
 }
 public ActionResult Edit([Bind(Include = "Id,ReporterId,ReportedId,ViolationId")] Violation violation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(violation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ReportedId = new SelectList(db.CppUsers, "Id", "AspNetUserId", violation.ReportedId);
     ViewBag.ReportedId = new SelectList(db.CppUsers, "Id", "AspNetUserId", violation.ReportedId);
     return(View(violation));
 }
 public ActionResult Edit([Bind(Include = "Id,CallSenderId,SessionBegin,SessionEnd,CallReceiverId,SessionString")] SessionLog sessionLog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sessionLog).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CallSenderId = new SelectList(db.CppUsers, "Id", "AspNetUserId", sessionLog.CallSenderId);
     ViewBag.CallReceiverId = new SelectList(db.CppUsers, "Id", "AspNetUserId", sessionLog.CallReceiverId);
     return View(sessionLog);
 }
Esempio n. 8
0
        public ActionResult Edit([Bind(Include = "Id,Subject,CourseNum,Semester,CourseName,CppUserId")] Cours cours)
        {
            if (isAdmin())
            {
                if (ModelState.IsValid)
                {
                    mDB.Entry(cours).State = EntityState.Modified;
                    mDB.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                ViewBag.CppUserId = new SelectList(mDB.CppUsers, "Id", "AspNetUserId", cours.CppUserId);
                return(View(cours));
            }

            Exception eNotAdmin = new Exception();

            return(View("Error", new HandleErrorInfo(eNotAdmin, "Cours", "Edit")));
        }