public ActionResult Index()
        {
            try
            {
                var Group = Connection.GDgetAllSubjectCategory("Y");
                List <GDgetAllSubjectCategory_Result> Grouplist = Group.ToList();

                SubjectCategoryModel tcm = new SubjectCategoryModel();

                List <SubjectCategoryModel> tcmlist = Grouplist.Select(x => new SubjectCategoryModel
                {
                    SubjectCategoryId   = x.SubjectCategoryId,
                    SubjectCategoryName = x.SubjectCategoryName,
                    CreatedBy           = x.CreatedBy,
                    CreatedDate         = x.CreatedDate,
                    IsActive            = x.IsActive,
                    ModifiedBy          = x.ModifiedBy,
                    ModifiedDate        = x.ModifiedDate
                }).ToList();



                return(View(tcmlist));
            }
            catch (Exception ex)
            {
                Errorlog.ErrorManager.LogError(ex);
                return(View());
            }
        }
 public ActionResult Delete(int Code)
 {
     try{
         SubjectCategoryModel TModel = new SubjectCategoryModel();
         TModel.SubjectCategoryId = Code;
         return(PartialView("DeleteView", TModel));
     }
     catch (Exception ex)
     {
         Errorlog.ErrorManager.LogError(ex);
         return(View());
     }
 }
        public ActionResult Delete(SubjectCategoryModel Model)
        {
            UserId = USession.User_Id;
            try
            {
                Connection.GDdeleteSubjectCategory("N", Model.SubjectCategoryId, UserId);
                Connection.SaveChanges();


                return(Json(true, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                Errorlog.ErrorManager.LogError(ex);
                return(View());
            }
        }
        public ActionResult Edit(SubjectCategoryModel Model)
        {
            UserId = USession.User_Id;
            try
            {
                tblSubjectCategory TCtable = Connection.tblSubjectCategories.SingleOrDefault(x => x.SubjectCategoryId == Model.SubjectCategoryId);

                Connection.GDModifySubjectCategory(Model.SubjectCategoryName, Model.SubjectCategoryId, UserId);
                Connection.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Errorlog.ErrorManager.LogError(ex);
                return(View());
            }
        }
        public ActionResult Edit(int Code)
        {
            try{
                SubjectCategoryModel TModel = new SubjectCategoryModel();

                tblSubjectCategory TCtable = Connection.tblSubjectCategories.SingleOrDefault(x => x.SubjectCategoryId == Code);
                TModel.IsActive = TCtable.IsActive;

                TModel.SubjectCategoryId   = TCtable.SubjectCategoryId;
                TModel.SubjectCategoryName = TCtable.SubjectCategoryName;

                return(PartialView("EditView", TModel));
            }
            catch (Exception ex)
            {
                Errorlog.ErrorManager.LogError(ex);
                return(View());
            }
        }
Exemplo n.º 6
0
        public async Task <IActionResult> AddSubjectCategory(SubjectCategoryBindingModel subjectCategoryBindingModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            var subjectCategoryModel = new SubjectCategoryModel
            {
                Description = subjectCategoryBindingModel.Description
            };
            var successful = await _subjectCategoryService.AddSubjectCategoryAsync(subjectCategoryModel);

            if (!successful)
            {
                return(BadRequest("Could not add the subject category"));
            }

            return(RedirectToAction("Index"));
        }