Exemplo n.º 1
0
        public ActionResult Create(TeacherCategoryModel Model)
        {
            try
            {
                tblTeacherCategory TCategory = new tblTeacherCategory();

                TCategory.CreatedBy           = "ADMIN";
                TCategory.CreatedDate         = DateTime.Now;
                TCategory.IsActive            = "Y";
                TCategory.TeacherCategoryId   = 0;
                TCategory.TeacherCategoryName = Model.TeacherCategoryName;

                Connection.tblTeacherCategories.Add(TCategory);
                Connection.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int CategoryId)
        {
            TeacherCategoryModel TModel = new TeacherCategoryModel();

            tblTeacherCategory TCtable = Connection.tblTeacherCategories.SingleOrDefault(
                x => x.TeacherCategoryId == CategoryId);

            TModel.TeacherCategoryName = TCtable.TeacherCategoryName;
            TModel.TeacherCategoryId   = TCtable.TeacherCategoryId;
            TModel.ModifiedBy          = "ADMIN"; //User session needed
            TModel.ModifiedDate        = DateTime.Now;

            return(PartialView("EditTeacherCategory", TModel));
        }
Exemplo n.º 3
0
        public ActionResult Edit(TeacherCategoryModel Model)
        {
            try
            {
                tblTeacherCategory TCtable = Connection.tblTeacherCategories.SingleOrDefault(
                    x => x.TeacherCategoryId == Model.TeacherCategoryId);
                TCtable.TeacherCategoryName = Model.TeacherCategoryName;
                TCtable.ModifiedBy          = "ADMIN";;
                TCtable.ModifiedDate        = DateTime.Now;
                Connection.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 4
0
        public ActionResult Delete(TeacherCategoryModel Model)
        {
            try
            {
                tblTeacherCategory TCtable = Connection.tblTeacherCategories.SingleOrDefault(
                    x => x.TeacherCategoryId == Model.TeacherCategoryId);
                TCtable.TeacherCategoryId = Model.TeacherCategoryId;
                TCtable.ModifiedBy        = "ADMIN";;
                TCtable.IsActive          = "N";
                TCtable.ModifiedDate      = DateTime.Now;
                Connection.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(View());
            }
        }