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 Delete(int CategoryId)
        {
            TeacherCategoryModel TModel = new TeacherCategoryModel();

            TModel.TeacherCategoryId = CategoryId;
            return(PartialView("DeleteTeacherCategory", TModel));
        }
Exemplo n.º 3
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.º 4
0
        public ActionResult Category()
        {
            List <tblUserCategory>   Categorylist = Connection.tblUserCategories.ToList();
            TeacherCategoryModel     tcm          = new TeacherCategoryModel();
            List <UserCategoryModel> tcmlist      = Categorylist.Select(x => new UserCategoryModel
            {
                CategoryId   = x.CategoryId,
                CategoryName = x.CategoryName,
                CreatedBy    = x.CreatedBy,
                CreatedDate  = x.CreatedDate,
                IsActive     = x.IsActive,
                ModifiedBy   = x.ModifiedBy,
                ModifiedDate = x.ModifiedDate
            }).ToList();

            return(View(tcmlist));
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            var Category = Connection.GDgetAllTeacherCategory("Y");
            List <GDgetAllTeacherCategory_Result> Categorylist = Category.ToList();
            TeacherCategoryModel        tcm     = new TeacherCategoryModel();
            List <TeacherCategoryModel> tcmlist = Categorylist.Select(x => new TeacherCategoryModel
            {
                TeacherCategoryId   = x.TeacherCategoryId,
                TeacherCategoryName = x.TeacherCategoryName,
                CreatedBy           = x.CreatedBy,
                CreatedDate         = x.CreatedDate,
                IsActive            = x.IsActive,
                ModifiedBy          = x.ModifiedBy,
                ModifiedDate        = x.ModifiedDate
            }).ToList();

            return(View(tcmlist));
        }
Exemplo n.º 6
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.º 7
0
        public ActionResult Index()
        {
            List <tblUser>       users   = Connection.tblUsers.ToList();
            TeacherCategoryModel tcm     = new TeacherCategoryModel();
            List <UserModel>     tcmlist = users.Select(x => new UserModel
            {
                UserId       = x.UserId,
                UserCategory = x.UserCategory,
                LoginEmail   = x.LoginEmail,
                PersonName   = x.PersonName,
                CreatedBy    = x.CreatedBy,
                CreatedDate  = x.CreatedDate,
                IsActive     = x.IsActive,
                ModifiedBy   = x.ModifiedBy,
                ModifiedDate = x.ModifiedDate
            }).ToList();

            return(View(tcmlist));
        }
Exemplo n.º 8
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());
            }
        }