public ActionResult Department(Sal_Dept_DesigModel objSal_Dept_Desig, string submit)
        {
            if (!String.IsNullOrEmpty(submit.Trim()))
            {
                DepartmentModel objDepartmentModel = new DepartmentModel();
                objDepartmentModel.Department   = objSal_Dept_Desig.Department;
                objDepartmentModel.DepartmentID = objSal_Dept_Desig.DepartmentID;
                switch (submit.Trim())
                {
                case "Update":
                    objDepartmentModel.AddEditDepartment(objDepartmentModel, clsCommon.Update);
                    BingModelData(objSal_Dept_Desig);
                    break;

                case "Add":
                    objDepartmentModel.AddEditDepartment(objDepartmentModel, clsCommon.Insert);
                    BingModelData(objSal_Dept_Desig);
                    break;

                case "Search":
                    BingModelData(objSal_Dept_Desig);
                    if (objSal_Dept_Desig.Department != null || !String.IsNullOrEmpty(objSal_Dept_Desig.Department))
                    {
                        objSal_Dept_Desig.departmentList = objDepartmentModel.GetDepartmentList(objSal_Dept_Desig.Department).ToList();
                    }
                    else
                    {
                        objSal_Dept_Desig.DepartmentID = 0;
                    }
                    break;
                }
            }
            return(View("~/Views/sal_Dept_Desig/Index.cshtml", objSal_Dept_Desig));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            AdminModel adminModel = new AdminModel();
            //List<CityModel> objCityModel = new List<CityModel>();
            Random rnd = new Random();

            using (CityModel objCityModel = new CityModel())
            {
                adminModel.cityList = objCityModel.GetCityList().OrderBy(o => rnd.Next()).Take(10).OrderBy(s => s.CityName).ToList();
            }

            // = objCityModel.OrderBy(u => rnd.Next(objCityModel.Count)).Take(10).ToList().OrderBy(m=>m.CityName).ToList();
            #region commented code Usefull do not delete
            //adminModel.stateList = objCityModel.OrderBy(k => k.StateName)
            //    .GroupBy(item => item.RefStateID, (key, items) => new StateModel
            //    {
            //        StateID = items.First().RefStateID,
            //        StateName = items.First().StateName,
            //        CountryName = items.First().Country,
            //        RefCountryID = items.First().RefCountryID
            //    }).ToList();

            //adminModel.countryList = objCityModel.OrderBy(c => c.Country)
            //    .GroupBy(item => item.RefCountryID, (key, items) => new CountryModel
            //    {
            //        CountryID = items.First().RefCountryID,
            //        Country = items.First().Country
            //    }).ToList();
            #endregion

            using (StateModel objState = new StateModel())
            {
                adminModel.stateList = objState.GetStateList().OrderBy(o => rnd.Next()).Take(10).OrderBy(s => s.StateName).ToList();
            }

            using (CountryModel objCountry = new CountryModel())
            {
                adminModel.countryList = objCountry.GetCountryList().OrderBy(o => rnd.Next()).Take(10).OrderBy(o => o.Country).ToList();
            }

            using (SalutationModel objSalutation = new SalutationModel())
            {
                adminModel.salutationList = objSalutation.GetSalutationList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Salutation).ToList();
            }

            using (DepartmentModel objDepartment = new DepartmentModel())
            {
                adminModel.departmentList = objDepartment.GetDepartmentList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Department).ToList();
            }

            using (DesignationModel objDesignation = new DesignationModel())
            {
                adminModel.designationList = objDesignation.GetDesignationList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Designation).ToList();
            }

            return(View(adminModel));
        }
        private void BingModelData(Sal_Dept_DesigModel objAdminModel)
        {
            using (SalutationModel objSalutationModel = new SalutationModel())
            {
                objAdminModel.salutationList = objSalutationModel.GetSalutationList().OrderBy(cc => cc.Salutation).ToList();
            }

            using (DepartmentModel objDepartment = new DepartmentModel())
            {
                objAdminModel.departmentList = objDepartment.GetDepartmentList().OrderBy(cc => cc.Department).ToList();
            }

            using (DesignationModel objDesignation = new DesignationModel())
            {
                objAdminModel.designationList = objDesignation.GetDesignationList().OrderBy(cc => cc.Designation).ToList();
            }
        }
        public ActionResult EditSalutation(string Id)
        {
            Sal_Dept_DesigModel objAdminModel = new Sal_Dept_DesigModel();

            using (SalutationModel objSalutation = new SalutationModel())
            {
                objAdminModel.salutationList = objSalutation.GetSalutationList().OrderBy(cc => cc.Salutation).ToList();
            }

            using (DepartmentModel objDepartment = new DepartmentModel())
            {
                objAdminModel.departmentList = objDepartment.GetDepartmentList().OrderBy(cc => cc.Department).ToList();
            }

            using (DesignationModel objDesignation = new DesignationModel())
            {
                objAdminModel.designationList = objDesignation.GetDesignationList().OrderBy(cc => cc.Designation).ToList();
            }
            return(View("~/Views/Sal_Dept_Desig/Index.cshtml", objAdminModel));
        }
        public ActionResult EditDepartment(int?Id)
        {
            Sal_Dept_DesigModel objAdminModel = new Sal_Dept_DesigModel();

            using (DepartmentModel objDepartment = new DepartmentModel())
            {
                objAdminModel.departmentList = objDepartment.GetDepartmentList().OrderBy(cc => cc.Department).ToList();
                objAdminModel.DepartmentID   = objAdminModel.departmentList.Where(m => m.DepartmentID == Id).SingleOrDefault().DepartmentID;
                objAdminModel.Department     = objAdminModel.departmentList.Where(m => m.DepartmentID == Id).SingleOrDefault().Department;
            }

            using (DesignationModel objDesignation = new DesignationModel())
            {
                objAdminModel.designationList = objDesignation.GetDesignationList().OrderBy(cc => cc.Designation).ToList();
            }

            using (SalutationModel objSalutation = new SalutationModel())
            {
                objAdminModel.salutationList = objSalutation.GetSalutationList().OrderBy(cc => cc.Salutation).ToList();
            }
            return(View("~/Views/Sal_Dept_Desig/Index.cshtml", objAdminModel));
        }