public ActionResult EditFaculties([Bind(Include = "id,FacultyName,ShortForm")] Faculty faculty)
        {
            if (!HasSession())
            {
                return(RedirectToAction("Index", "Home"));
            }

            faculty.ShortForm = faculty.ShortForm.ToUpper();

            Faculty oldFaculty = db.Faculty.Find(faculty.id);

            db.Entry(oldFaculty).State = EntityState.Detached;
            Boolean ck = false;

            if (!faculty.ShortForm.Equals(oldFaculty.ShortForm))
            {
                CreateDatabaseAndTable cdt = new CreateDatabaseAndTable(oldFaculty.ShortForm);
                ck = cdt.AlterDatabase(oldFaculty.ShortForm, faculty.ShortForm);
            }

            if (ck == false)
            {
                return(View(db.Faculty.Find(faculty.id)));
            }

            if (ModelState.IsValid)
            {
                db.Entry(faculty).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ManageFaculty", "Faculty"));
        }
Beispiel #2
0
        public ActionResult EditTeacher([Bind(Include = "TeacherID,Name,Email,Mobile,Faculty,Department,Password")] Teacher teacher)
        {
            Teacher tcr = db.Teacher.Find(teacher.TeacherID);

            db.Entry(tcr).State = EntityState.Detached;

            if (tcr.PasswordChanged == true)
            {
                EncryptionDectryption sc = new EncryptionDectryption();
                teacher.Password        = sc.Encryptdata(teacher.Password);
                teacher.PasswordChanged = true;
            }


            if (teacher.Password.Equals(tcr.Password))
            {
                if (ModelState.IsValid)
                {
                    db.Entry(teacher).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("TeachersList", "Admin"));
            }
            else
            {
                ViewBag.Message = "Please Put the correct password";
                return(View());
            }
        }
        public ActionResult EditCourse([Bind(Include = "id,Course_code,Course_title,Credit_hour,Semester,UnderFaculty,CourseTeacherID")] Course course)
        {
            if (!HasSession()) return RedirectToAction("Index", "Home");

            Course crs = db.Courses.Find(course.id);
            db.Entry(crs).State = EntityState.Detached;
            course.Course_code = course.Course_code.Trim().Replace(" ", "_").Replace("-", "_").ToUpper();

            if (!crs.Course_code.Equals(course.Course_code))
            {
                CreateDatabaseAndTable cdt = new CreateDatabaseAndTable(crs.UnderFaculty);
                cdt.AlterCourseTable(crs.Course_code, course.Course_code);
                string table = (course.Semester % 2 == 1) ? "JanEnrollment" : "JulEnrollment";
                cdt.RenameTableColumn(table, crs.Course_code, course.Course_code);

            }
            if (ModelState.IsValid)
            {
                Teacher tcr = db.Teacher.Where(dp => dp.TeacherID == course.CourseTeacherID).FirstOrDefault();
                if (tcr != null)
                {
                    course.CourseTeacherName = tcr.Name;
                    course.CourseTeacherDepartment = tcr.Department;
                    course.CourseTeacherFaculty = tcr.Faculty;
                }
                db.Entry(course).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.Message = course.Course_code + " Updated!";
            }
            else ViewBag.Error = course.Course_code + " Not Updated!";

            return RedirectToAction("ManageCourse", "Course");
        }
Beispiel #4
0
        private void btnNew_Click(object sender)
        {
            entity.project project = new  entity.project();
            project.IsSelected = true;

            ProjectDB.Entry(project).State = EntityState.Added;
            ProjectViewSource.View.MoveCurrentToLast();
        }
Beispiel #5
0
        public IHttpActionResult PutPinLocation(short lid, PinLocation pinLocation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (lid != pinLocation.PinId)
            {
                return(BadRequest());
            }

            db.Entry(pinLocation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PinLocationExists(lid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.Id)
            {
                return(BadRequest());
            }

            db.Entry(product).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #7
0
        public IHttpActionResult PutStation(short id, Station station)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != station.SID)
            {
                return(BadRequest());
            }

            _context.Entry(station).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.Created));
        }
Beispiel #8
0
        public IHttpActionResult UpdateTrain(short id, Train train)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != train.TID)
            {
                return(BadRequest());
            }

            _context.Entry(train).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrainExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #9
0
        public ActionResult EditDepartments([Bind(Include = "id,DepartmentName,ShortForm,Faculty,ChairmanId")] Department department)
        {
            if (!HasSession())
            {
                return(RedirectToAction("Index", "Home"));
            }

            department.ShortForm = department.ShortForm.ToUpper();
            department.Faculty   = department.Faculty.ToUpper();

            Teacher tcr = db.Teacher.Where(a => a.TeacherID == department.ChairmanId && a.Faculty == department.Faculty).FirstOrDefault();

            if (tcr != null)
            {
                department.ChairmanName  = tcr.Name;
                department.ChairmanId    = tcr.TeacherID;
                department.ChairmanEmail = tcr.Email;
            }
            else
            {
                department.ChairmanName  = null;
                department.ChairmanId    = 0;
                department.ChairmanEmail = null;
            }

            if (ModelState.IsValid)
            {
                db.Entry(department).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ManageDepartment", "Department"));
        }
Beispiel #10
0
        public IHttpActionResult PutStopAt(short sid, short tid, StopAt stopAt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (sid != stopAt.SID || tid != stopAt.TID)
            {
                return(BadRequest());
            }

            _dbContext.Entry(stopAt).State = EntityState.Modified;

            try
            {
                _dbContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StopAtExists(sid) || !StopAtExists(tid))
                {
                    return(NotFound());
                }
                else
                {
                    return(Conflict());
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult ChangePassword(int?TeacherID, String oldpassword, String newpassword, String retypenewpassword)
        {
            if (!HasSession())
            {
                return(RedirectToAction("Index", "Home"));
            }

            Teacher teacher = db.Teacher.Find(TeacherID);

            if (newpassword.Equals(retypenewpassword))
            {
                if (teacher.Password.Equals(oldpassword))
                {
                    teacher.Password = newpassword;

                    db.Entry(teacher).State = EntityState.Modified;
                    db.SaveChanges();

                    ViewBag.Message = "Successfully password changed";
                    //return RedirectToAction("index", "Teacher");
                    return(View(teacher));
                }
                else
                {
                    ViewBag.Message = "Invalid Old Password..!";

                    return(View(teacher));
                }
            }
            else
            {
                ViewBag.Message = "Miss Match new Password..!";
                return(View(teacher));
            }
        }
Beispiel #12
0
 public ActionResult Edit([Bind(Include = "id,Name,age")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Beispiel #13
0
        public ActionResult EditFaculties([Bind(Include = "id,FacultyName,ShortForm")] Faculty faculty)
        {
            if (ModelState.IsValid)
            {
                db.Entry(faculty).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ManageFaculty", "Faculty"));
        }
Beispiel #14
0
        public ActionResult EditDepartments([Bind(Include = "id,DepartmentName,ShortForm,Faculty")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Entry(department).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ManageDepartment", "Department"));
        }
 public ActionResult Edit([Bind(Include = "Id,BrandName,Code,BrandDescription")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Beispiel #16
0
 public ActionResult Edit([Bind(Include = "DepartmentCourseID,CourseID")] DepartmentCourse departmentCourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departmentCourse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(departmentCourse));
 }
 public ActionResult Edit([Bind(Include = "contactID,Adress,phone")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         logger.Info($" AN ADMIN  EDIT A CONTACT : {contact.contactID}--------ADMIN :{Session["UserName"]}--ID:{Session["ID"]}");
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
 public ActionResult Edit([Bind(Include = "Id,ProductName,ProductCode,ProductPrice,ProductDescription,ProductId")] ProductItem productItem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productItem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Products, "Id", "BrandName", productItem.ProductId);
     return(View(productItem));
 }
 public ActionResult Edit([Bind(Include = "CommentID,UserName,Email,Comment1,blogID,UserID,validation")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CommentID = new SelectList(db.Blogs, "blogID", "title", comment.CommentID);
     ViewBag.CommentID = new SelectList(db.Users, "ID", "Name", comment.CommentID);
     logger.Info($" AN ADMIN EDIT COMMENTS :COMMENT ID {comment.CommentID}-- BLOG ID:{comment.blogID}--------ADMIN :{Session["UserName"]}--ID:{Session["ID"]}");
     return(View(comment));
 }
 public ActionResult UserPageEditComments([Bind(Include = "CommentID,UserName,Email,Comment1,blogID,UserID,validation")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("UserPage"));
     }
     ViewBag.CommentID = new SelectList(db.Blogs, "blogID", "title", comment.CommentID);
     ViewBag.CommentID = new SelectList(db.Users, "ID", "Name", comment.CommentID);
     logger.Info($"COMMENTS EDITTED=> NAME :{Session["UserName"]}-- ID:{Session["ID"]}-- ROLE:{Session["ROLE"]}");
     return(View(comment));
 }
Beispiel #21
0
        public ActionResult EditTeacher([Bind(Include = "TeacherID,Name,Email,Mobile,Faculty,Department")] Teacher teacher)
        {
            if (!HasSession())
            {
                return(RedirectToAction("Index", "Home"));
            }

            teacher.Faculty    = teacher.Faculty.ToUpper();
            teacher.Department = teacher.Department.ToUpper();

            Teacher tcr = db.Teacher.Find(teacher.TeacherID);

            db.Entry(tcr).State = EntityState.Detached;

            teacher.Password = tcr.Password;

            if (ModelState.IsValid)
            {
                db.Entry(teacher).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("TeachersList", "Admin"));
        }
        public ActionResult ChangePassword(int? TeacherID, String oldpassword, String newpassword, String retypenewpassword)
        {


            Teacher teacher = db.Teacher.Find(TeacherID);

            if (newpassword.Equals(retypenewpassword))
            {

                if (teacher.PasswordChanged == true)
                {
                    oldpassword = new EncryptionDectryption().Encryptdata(oldpassword);
                }

                if(teacher.Password.Equals(oldpassword)){
                    teacher.Password = new EncryptionDectryption().Encryptdata(newpassword);
                    teacher.PasswordChanged = true;
                    db.Entry(teacher).State = EntityState.Modified;
                    db.SaveChanges();


                    ViewBag.Message = "Successfully password changed";
                    return RedirectToAction("index", "Teacher");
                }
                else
                {
                    ViewBag.Message = "Invalid Old Password..!";
                    
                    return View(teacher);
                }


            }
            else
            {
                ViewBag.Message = "Miss Match new Password..!";
                return View(teacher);
            }

              

        }