//
        // GET: /Section/
        public ActionResult Index()
        {
            SessionMasterModel objSessionModel = new SessionMasterModel();
            ClassMasterModel   objClassModel   = new ClassMasterModel();

            objBDCCommon = new CommonMasterDataBusiness();

            var SessionType = objBDCCommon.GetSessionMaster();

            objSessionModel.SessionList = new SelectList(SessionType, "SessionId", "Title");
            ViewBag.SessionInfo         = objSessionModel.SessionList;

            var ClassType = objBDCCommon.GetClassMaster(Convert.ToInt32(Session[CommonStrings.DefaultSession]));

            objClassModel.ClassList = new SelectList(ClassType, "ClassId", "Title");
            ViewBag.ClassInfo       = objClassModel.ClassList;

            SectionMasterCustomModel objModel = new SectionMasterCustomModel();

            objBDC             = new SectionMasterBusiness();
            objModel.SessionId = Convert.ToInt32(Session[CommonStrings.DefaultSession]);
            var rs = objBDC.GetSectionMasterListing(objModel);

            ViewBag.SessionValue = Session[CommonStrings.DefaultSession].ToString();

            return(View(rs));
        }
Example #2
0
 public object DeleteSectionRegistrationDetail(SectionMasterCustomModel objSectionRegistrationModel)
 {
     using (objDAL = new SectionMasterRepo())
     {
         return(objDAL.DeleteSectionRegistrationDetail(objSectionRegistrationModel));
     }
 }
Example #3
0
 public Response SaveSectionMasterDetails(SectionMasterCustomModel objModel)
 {
     using (objDAL = new SectionMasterRepo())
     {
         return(objDAL.SaveSectionMasterDetails(objModel));
     }
 }
Example #4
0
 public object GetSectionMasterListing(SectionMasterCustomModel objSectionRegistrationModel)
 {
     using (objDAL = new SectionMasterRepo())
     {
         return(objDAL.GetSectionMasterListing(objSectionRegistrationModel));
     }
 }
        public ActionResult SearchSessionWiseResult(int?SessionId, int?ClassId)
        {
            SectionMasterCustomModel objModel = new SectionMasterCustomModel();

            objBDC             = new SectionMasterBusiness();
            objModel.SessionId = SessionId;
            objModel.ClassId   = ClassId;
            var rs = objBDC.GetSectionMasterListing(objModel);

            @ViewBag.TotalStudents = rs.ToString().Count();
            return(PartialView(rs));
        }
        public ActionResult Create(SectionMasterCustomModel objModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Response _Result = new Response();
                    // TODO: Add insert logic here
                    objBDC              = new SectionMasterBusiness();
                    objModel.CreatedBy  = ((School.Shared.CustomModels.UserLoginCustomModel)(Session[CommonStrings.UserSession])).Id;
                    objModel.ModifiedBy = ((School.Shared.CustomModels.UserLoginCustomModel)(Session[CommonStrings.UserSession])).Id;
                    _Result             = objBDC.SaveSectionMasterDetails(objModel);

                    if (_Result.success == true)
                    {
                        TempData["Message"] = "Success^" + _Result.message;
                    }
                    else if (_Result.success == false)
                    {
                        TempData["Message"] = "Error^" + _Result.message;
                    }

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ClassMasterModel   objClassModel   = new ClassMasterModel();
                    SessionMasterModel objSessionModel = new SessionMasterModel();
                    objBDCCommon = new CommonMasterDataBusiness();

                    var SessionType = objBDCCommon.GetSessionMaster();
                    objSessionModel.SessionList = new SelectList(SessionType, "SessionId", "Title");
                    ViewBag.SessionInfo         = objSessionModel.SessionList;

                    var ClassType = objBDCCommon.GetClassMaster(Convert.ToInt32(Session[CommonStrings.DefaultSession]));
                    objClassModel.ClassList = new SelectList(ClassType, "ClassId", "Title");
                    ViewBag.ClassInfo       = objClassModel.ClassList;

                    ViewBag.SessionValue = Session[CommonStrings.DefaultSession].ToString();

                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, SectionMasterCustomModel objModel)
        {
            try
            {
                // TODO: Add update logic here
                objBDC             = new SectionMasterBusiness();
                objModel.SectionId = id;
                objBDC.SaveSectionMasterDetails(objModel);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public SectionMasterCustomModel GetById(int Id)
        {
            SectionMasterCustomModel SectionListModel = new SectionMasterCustomModel();

            using (response = new Response())
            {
                using (dbcontext = new SchoolManagementEntities())
                {
                    try
                    {
                        response.success = true;

                        SectionListModel = dbcontext.tblSections.Where(x => x.IsDeleted == false && x.SectionId == Id)
                                           .Select(x => new SectionMasterCustomModel
                        {
                            SectionId        = x.SectionId,
                            SchoolId         = x.SchoolId,
                            SchoolName       = x.SchoolId != null ? x.tblSchool.Name : "",
                            SessionId        = x.ClassId != null ? x.tblClass.SessionId : 0,
                            ClassId          = x.ClassId,
                            ClassName        = x.ClassId != null ? x.tblClass.Title : "",
                            Title            = x.Title,
                            Image            = x.Image,
                            DDate            = x.DDate,
                            ShortDescription = x.ShortDescription,
                            IsActive         = x.IsActive,
                            IsDeleted        = x.IsDeleted,
                            CreatedBy        = x.CreatedBy,
                            CreatedDate      = x.CreatedDate,
                            ModifiedBy       = x.ModifiedBy,
                            ModifiedDate     = x.ModifiedDate
                        }).SingleOrDefault();
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        SectionListModel = null;
                    }
                }
            }
            return(SectionListModel);
        }
        public JsonResult UpdateStatus(string id)
        {
            objBDC = new SectionMasterBusiness();
            int  Id      = Convert.ToInt32(id);
            bool _Result = objBDC.FindById(Id);

            if (_Result == true)
            {
                _Result = false;
            }
            else
            {
                _Result = true;
            }

            SectionMasterCustomModel objModel = new SectionMasterCustomModel();

            objModel.SectionId = Id;
            objBDC.SetActiveSectionRegistrationDetail(objModel);
            return(Json(new { result = _Result }));
        }
        /// <summary>
        /// This method is used to delete particular farmer detail
        /// </summary>
        /// <param name="AssetId">Unique id of asset</param>
        /// <returns>Response</returns>
        public object DeleteSectionRegistrationDetail(SectionMasterCustomModel objSectionRegistrationModel)
        {
            object objSectionResult = new object();

            using (response = new Response())
            {
                using (dbcontext = new SchoolManagementEntities())
                {
                    try
                    {
                        var rs = dbcontext.tblSections.FirstOrDefault(x => x.SectionId == objSectionRegistrationModel.SectionId);

                        if (rs != null)
                        {
                            rs.IsDeleted    = true;
                            rs.ModifiedDate = DateTime.Now;
                            rs.ModifiedBy   = objSectionRegistrationModel.ModifiedBy;

                            dbcontext.SaveChanges();
                            objSectionResult = true;
                        }
                        else
                        {
                            objSectionResult = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        dbcontext.Dispose();
                        objSectionResult = null;
                        throw ex;
                    }
                }
                return(objSectionResult);
            }
        }
        //
        // GET: /Section/Create
        public ActionResult Create(int id = 0)
        {
            SectionMasterCustomModel objModel        = new SectionMasterCustomModel();
            ClassMasterModel         objClassModel   = new ClassMasterModel();
            SessionMasterModel       objSessionModel = new SessionMasterModel();

            objBDCCommon = new CommonMasterDataBusiness();

            var SessionType = objBDCCommon.GetSessionMaster();

            objSessionModel.SessionList = new SelectList(SessionType, "SessionId", "Title");
            ViewBag.SessionInfo         = objSessionModel.SessionList;

            if (id > 0)
            {
                objBDC   = new SectionMasterBusiness();
                objModel = objBDC.GetById(id);

                var ClassType = objBDCCommon.GetClassMaster(Convert.ToInt32(objModel.SessionId));
                objClassModel.ClassList = new SelectList(ClassType, "ClassId", "Title");
                ViewBag.ClassInfo       = objClassModel.ClassList;

                ViewBag.ClassValue   = Convert.ToString(objModel.ClassId);
                ViewBag.SessionValue = Convert.ToString(objModel.SessionId);
            }
            else
            {
                var ClassType = objBDCCommon.GetClassMaster(Convert.ToInt32(Session[CommonStrings.DefaultSession]));
                objClassModel.ClassList = new SelectList(ClassType, "ClassId", "Title");
                ViewBag.ClassInfo       = objClassModel.ClassList;

                ViewBag.SessionValue = Session[CommonStrings.DefaultSession].ToString();
            }

            return(View(objModel));
        }
        public object GetSectionMasterListing(SectionMasterCustomModel objSectionRegistrationModel)
        {
            IList <SectionMasterCustomModel>      SectionListModel  = new List <SectionMasterCustomModel>();
            IQueryable <SectionMasterCustomModel> SectionListDetail = null;
            int TotalRec        = 0;
            int CurrentPageSize = 0;

            using (response = new Response())
            {
                using (dbcontext = new SchoolManagementEntities())
                {
                    try
                    {
                        response.success = true;

                        SectionListDetail = dbcontext.tblSections.Where(x => x.IsDeleted == false &&
                                                                        (objSectionRegistrationModel.SessionId == null || objSectionRegistrationModel.SessionId == 0 || x.tblClass.SessionId == objSectionRegistrationModel.SessionId) &&
                                                                        (objSectionRegistrationModel.ClassId == null || objSectionRegistrationModel.ClassId == 0 || x.ClassId == objSectionRegistrationModel.ClassId)
                                                                        )
                                            .Select(x => new SectionMasterCustomModel
                        {
                            SectionId        = x.SectionId,
                            SchoolId         = x.SchoolId,
                            SchoolName       = x.tblSchool != null ? x.tblSchool.Name : "",
                            ClassId          = x.ClassId,
                            ClassName        = x.tblClass != null ? x.tblClass.Title : "",
                            Title            = x.Title,
                            Image            = x.Image,
                            DDate            = x.DDate,
                            ShortDescription = x.ShortDescription,
                            IsActive         = x.IsActive,
                            IsDeleted        = x.IsDeleted,
                            CreatedBy        = x.CreatedBy,
                            CreatedDate      = x.CreatedDate,
                            ModifiedBy       = x.ModifiedBy,
                            ModifiedDate     = x.ModifiedDate
                        }).OrderByDescending(x => x.SectionId);

                        if (objSectionRegistrationModel.pageModel != null)
                        {
                            if (objSectionRegistrationModel.pageModel.SerachTerm != null && objSectionRegistrationModel.pageModel.SerachTerm != "")
                            {
                                SectionListDetail = SectionListDetail.Where(x =>
                                                                            (x.Title.ToLower().Trim().Contains(objSectionRegistrationModel.pageModel.SerachTerm.ToLower().Trim()) || objSectionRegistrationModel.pageModel.SerachTerm.Trim() == String.Empty) ||
                                                                            (x.ShortDescription.ToLower().Trim().Contains(objSectionRegistrationModel.pageModel.SerachTerm.ToLower().Trim()) || objSectionRegistrationModel.pageModel.SerachTerm.Trim() == String.Empty)
                                                                            );
                            }

                            if (!String.IsNullOrEmpty(objSectionRegistrationModel.pageModel.SortBy))
                            {
                                //SectionListDetail= objSectionRegistrationModel.pageModel.SortDir.ToLower() == "desc" ? SectionListDetail.OrderByDescending(objSectionRegistrationModel.pageModel.SortBy)
                                //    : SectionListDetail.OrderBy(objSectionRegistrationModel.pageModel.SortBy);
                            }

                            TotalRec = SectionListDetail.Count();
                            if (objSectionRegistrationModel.pageModel.PageSize > 0)
                            {
                                SectionListDetail = SectionListDetail.Skip(objSectionRegistrationModel.pageModel.Skip);
                                SectionListDetail = SectionListDetail.Take(objSectionRegistrationModel.pageModel.PageSize);
                            }

                            SectionListModel = SectionListDetail.ToList() as IList <SectionMasterCustomModel>;
                        }
                        else
                        {
                            TotalRec         = SectionListDetail.Count();
                            SectionListModel = SectionListDetail.ToList() as IList <SectionMasterCustomModel>;
                        }

                        //CurrentPageSize = objSectionRegistrationModel.pageModel.PageSize;

                        //if (SectionListModel.Count() > 0 && CurrentPageSize > 0)
                        //{
                        //    SectionListModel[0].pageModel = new PagingViewModel();

                        //    SectionListModel[0].pageModel.TotalRecords = TotalRec;
                        //    if ((TotalRec % CurrentPageSize) == 0)
                        //    {
                        //        SectionListModel[0].pageModel.TotalPages = TotalRec / CurrentPageSize;
                        //    }
                        //    else
                        //    {
                        //        SectionListModel[0].pageModel.TotalPages = (TotalRec / CurrentPageSize) + 1;
                        //    }
                        //}

                        return(SectionListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
        public Response SaveSectionMasterDetails(SectionMasterCustomModel objModel)
        {
            using (response = new Response())
            {
                using (dbcontext = new SchoolManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        if (objModel.SectionId == 0)
                        {
                            var rs = dbcontext.tblSections.FirstOrDefault(x => x.IsDeleted == false && x.Title == objModel.Title && x.ClassId == objModel.ClassId);
                            if (rs == null)
                            {
                                tblSection objAddNew = new tblSection
                                {
                                    ClassId          = objModel.ClassId,
                                    SchoolId         = Convert.ToInt32(CommonHelper.TaskSchoolId.SchoolId),
                                    Title            = objModel.Title,
                                    ShortDescription = objModel.ShortDescription,
                                    DDate            = objModel.DDate,

                                    IsActive     = true,
                                    IsDeleted    = false,
                                    CreatedBy    = objModel.CreatedBy,
                                    CreatedDate  = DateTime.Now,
                                    ModifiedBy   = objModel.ModifiedBy,
                                    ModifiedDate = DateTime.Now
                                };

                                dbcontext.tblSections.Add(objAddNew);
                                dbcontext.SaveChanges();
                                response.responseData = new { SectionId = objAddNew.SectionId, Title = objAddNew.Title };
                                response.message      = "Record Added Successfully!";
                            }
                            else
                            {
                                response.success = false;
                                response.message = "Record Already Exists!";
                            }
                        }
                        else
                        {
                            var rs = dbcontext.tblSections.FirstOrDefault(x => x.IsDeleted == false && x.ClassId == objModel.ClassId && x.Title == objModel.Title && x.SectionId != objModel.SectionId);
                            if (rs == null)
                            {
                                var objUpdate = dbcontext.tblSections.FirstOrDefault(m => m.SectionId == objModel.SectionId);
                                if (objUpdate != null)
                                {
                                    objUpdate.ClassId          = objModel.ClassId;
                                    objUpdate.Title            = objModel.Title;
                                    objUpdate.ShortDescription = objModel.ShortDescription;
                                    objUpdate.DDate            = objModel.DDate;

                                    objUpdate.ModifiedBy   = objModel.ModifiedBy;
                                    objUpdate.ModifiedDate = DateTime.Now;
                                    dbcontext.SaveChanges();
                                    response.responseData = new { SectionId = objUpdate.SectionId, Title = objUpdate.Title };
                                    response.message      = "Record Updated Successfully!";
                                }
                            }
                            else
                            {
                                response.success = false;
                                response.message = "Record Already Exists!";
                            }
                        }
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }