Exemplo n.º 1
0
        public ActionResult DeleteCourse(string id)
        {
            var course = db.Courses.Find(id);

            course.Visible = false;
            db.SaveChanges();
            return(RedirectToAction("getAllCourses"));
        }
Exemplo n.º 2
0
        public ActionResult Delete_course(string Course_Code, string title)
        {
            var del_course = db.Exercises.FirstOrDefault(ww => ww.Course_Code == Course_Code && ww.Title == title);

            del_course.Is_Active = false;
            db.SaveChanges();
            return(RedirectToAction("GetExercises"));
        }
Exemplo n.º 3
0
        public ActionResult EditProf(Student std, HttpPostedFileBase Poster)
        {
            var ad = db.Students.Any(ww => ww.UserName == std.UserName && ww.Student_Code != std.Student_Code);

            if (ad)
            {
                ViewBag.error    = "This UserName Is Already Exist!!";
                ViewBag.DeptList = new SelectList(db.Departments.ToList(), "Dept_Id", "DeptName", std.Dept_Id);
                return(View("Editprofile", std));
            }


            if (ModelState.IsValid)
            {
                std.Gender     = Session["gender"].ToString();
                std.Admin_Id   = int.Parse(Session["admin_id"].ToString());
                std.Attendence = int.Parse(Session["attendance"].ToString());
                std.Visible    = bool.Parse(Session["visible"].ToString());
                std.BirthDate  = DateTime.Parse(Session["bd"].ToString());
                std.Type       = Session["type"].ToString();

                if (Poster != null && Poster.ContentLength > 0)
                {
                    Poster.SaveAs(Server.MapPath($"~/Images/{Poster.FileName}"));
                    std.Photo = Poster.FileName;
                }
                if (std.Photo == null)
                {
                    std.Photo = "user2.png";
                }

                db.Entry(std).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction($"StudentCourses/{std.Student_Code}"));
            }
            ViewBag.DeptList = new SelectList(db.Departments.ToList(), "Dept_Id", "DeptName", std.Dept_Id);
            return(View("Editprofile", std));
        }
Exemplo n.º 4
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind <Event>(actionValues);
            var entities     = new ELearning();

            //try
            //{
            switch (action.Type)
            {
            case DataActionTypes.Insert:
                entities.Events.Add(changedEvent);
                break;

            case DataActionTypes.Delete:
                changedEvent = entities.Events.FirstOrDefault(ev => ev.id == action.SourceId);
                entities.Events.Remove(changedEvent);
                break;

            default:        // "update"
                var target = entities.Events.Single(e => e.id == changedEvent.id);
                DHXEventsHelper.Update(target, changedEvent, new List <string> {
                    "id"
                });
                break;
            }
            entities.SaveChanges();
            action.TargetId = changedEvent.id;
            //}
            //catch (Exception a)
            //{
            //    action.Type = DataActionTypes.Error;
            //}

            return(new AjaxSaveResponse(action));
        }