コード例 #1
0
        public ActionResult EditEducation(EmpEducationDTO data)
        {
            data.PassedDate = Convert.ToDateTime(NepEngDate.NepToEng(data.PassedDateNP));

            data.EmpCode         = Convert.ToInt32(Session["EmpCode"]);
            data.EducationStatus = 0;
            EmpEducationDTO       jtd            = new EmpEducationDTO();
            List <SelectListItem> educationLevel = new List <SelectListItem>();

            foreach (var row in _educationLevel.GetEducationLevel())
            {
                educationLevel.Add(new SelectListItem
                {
                    Text  = row.LevelName,
                    Value = row.LevelId.ToString()
                });
            }
            IEnumerable <SelectListItem> CountryList = _countryService.GetCountryList();

            ViewBag.Countries      = CountryList;
            ViewBag.EducationLevel = educationLevel;
            //if (!ModelState.IsValid)
            //{
            //    return View(jtd);
            //}
            if (data.EducationStatus == 0)
            {
                if (data.File != null)
                {
                    string extension = Path.GetExtension(data.File.FileName).ToLower();
                    if (extension == ".jpeg" || extension == ".jpg" || extension == ".png")
                    {
                        data.ScanDocument = (data.EduId + data.File.FileName).ToLower();
                        //housePermitModel = _housePermitService.insertHousePermits(housePermit);
                        if (data != null)
                        {
                            string path = Server.MapPath("~\\img\\");
                            data.File.SaveAs(path + data.ScanDocument);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("InvalidImage", "The file you are trying to upload is not image.");
                        return(View());
                    }
                }
                int res = _empEducationService.UpdateEducation(data);
                ViewBag.Success = "Education of " + data.EmpCode + " has been updated";
                ModelState.Clear();
                return(View(jtd));
            }
            else
            {
                ViewBag.Success = "Education already approved ";
                return(View(jtd));
            }
        }
コード例 #2
0
        public ActionResult EducationEdit(EmpEducationDTO data)
        {
            data.PassedDate = !string.IsNullOrEmpty(data.PassedDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(data.PassedDateNP)) : data.PassedDate;

            if (!ViewBag.AllowEdit)
            {
                ViewBag.Error = "You are not Authorize to use this Page";
                return(PartialView("_partialviewNotFound"));
            }
            try
            {
                ViewBag.SideBar = _moduleService.AdminEmployeeDetailsMenu(data.EmpCode);
                List <SelectListItem> educationLevel = new List <SelectListItem>();
                foreach (var row in _educationLevel.GetEducationLevel())
                {
                    educationLevel.Add(new SelectListItem
                    {
                        Text  = row.LevelName,
                        Value = row.LevelId.ToString()
                    });
                }
                IEnumerable <SelectListItem> countries = _countryService.GetCountryList();
                ViewBag.Countries      = countries;
                ViewBag.EducationLevel = educationLevel;
                ViewBag.EmployeeDetail = _empDetails.GetEmployeeDetails(data.EmpCode);
                if (!ModelState.IsValid)
                {
                    return(View("../Employee/Education/EducationEdit", data));
                }
                int res = _empEducationService.UpdateEducation(data);
                if (res > 0)
                {
                    ViewBag.Success = "Education updated successfully";
                }
                else
                {
                    ViewBag.Error = "Couldn't update";
                }
                return(Redirect("/education/" + data.EmpCode));
            }
            catch (Exception ex)
            {
                ViewBag.EmployeeDetail = _empDetails.GetEmployeeDetails(data.EmpCode);
                ViewBag.SideBar        = _moduleService.AdminEmployeeDetailsMenu(data.EmpCode);
                ViewBag.Error          = ex.Message;
                return(View("../Employee/Education/EducationEdit", data));
            }
        }