public void Update(EmpAllItem model) { Mapper.CreateMap <EmployeeItem, employee_master>(); employee_master objmaster = DbContext.employee_master.SingleOrDefault(m => m.id == model.EmployeeItem.id); objmaster = Mapper.Map(model.EmployeeItem, objmaster); DbContext.SaveChanges(); }
public int Insert(EmpAllItem model) { try { Mapper.CreateMap <EmployeeItem, employee_master>(); employee_master objEmp = Mapper.Map <employee_master>(model.EmployeeItem); DbContext.employee_master.Add(objEmp); DbContext.SaveChanges(); int p = DbContext.employee_master.Max(item => item.id); if (p != 0) { //For inserting values in EmployeeRelative table //model.EmpRelativeItem.EmpId = p; //model.EmpContactItem.EmpId = p; //model.EmpPassportItem.EmpId = p; } //Mapper.CreateMap<EmpRelativeItem, EmployeeRelative>(); //EmployeeRelative objRelative = Mapper.Map<EmployeeRelative>(model.EmpRelativeItem); //DbContext.EmployeeRelatives.Add(objRelative); //DbContext.SaveChanges(); // For inserting values in EmployeeContact table //Mapper.CreateMap<EmpContactItem, EmployeeContact>(); //EmployeeContact objEmpCont = Mapper.Map<EmployeeContact>(model.EmpContactItem); //DbContext.EmployeeContacts.Add(objEmpCont); //DbContext.SaveChanges(); //// For inserting values in EmployeePassport Table //Mapper.CreateMap<EmpPassportItem, EmployeePassport>(); //EmployeePassport objPassport = Mapper.Map<EmployeePassport>(model.EmpPassportItem); //DbContext.EmployeePassports.Add(objPassport); //DbContext.SaveChanges(); return(DbContext.employee_master.Max(item => item.id)); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation( "Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } return(1); } }
//[HttpPost] //public ActionResult Create(EmployeeItem model) //{ // if (model.Empname != null) // { // EmployeeService objEmpService = new EmployeeService(); // HttpPostedFileBase file = Request.Files["file"]; // var fileName = Path.GetFileName(file.FileName); // var path = Path.Combine(Server.MapPath("../PhotoUpload"), fileName); // file.SaveAs(path); // model.Photo = fileName; // model.CreatedDate = System.DateTime.Now; // int p = objEmpService.Insert(model); // return RedirectToAction("Create", "Employee"); // } // else // { // ModelState.AddModelError("", ""); // return RedirectToAction("Create", "Employee"); // } //} public ActionResult View(int id) { EmployeeService objmethod = new EmployeeService(); EmployeeItem objmaster = new EmployeeItem(); objmaster = objmethod.GetById(id); Session["PhotoId"] = objmaster.Photo; List <EmployeeItem> lstmasterp = new List <EmployeeItem>(); objmaster.EmployeeList = new List <EmployeeItem>(); objmaster.EmployeeList.AddRange(lstmasterp); //Added by Kuldip Patel @07-06-2016 #region Bind RDB Working Status List <clsMasterData> lstMasters1 = new List <clsMasterData>(); EmployeeService objclsmethod = new EmployeeService(); lstMasters1 = objclsmethod.GetWorkingStatus(); EmployeeItem objItem = new EmployeeItem(); objmaster.listMasterWS = new List <clsMasterData>(); objmaster.listMasterWS.AddRange(lstMasters1); #endregion #region Company Bind List <CompanyItem> objCompany = new List <CompanyItem>(); CompanyService objListCompany = new CompanyService(); objCompany = objListCompany.GetALL(); objmaster.CompanyList = new List <CompanyItem>(); objmaster.CompanyList.AddRange(objCompany); #endregion //For Bind Branch #region Bind Branch List <BranchItem> objbranchitm = new List <BranchItem>(); BranchService objbranchservice = new BranchService(); objbranchitm = objbranchservice.GetAll(); //objEmpItem = new EmployeeItem(); objmaster.BranchList = new List <BranchItem>(); objmaster.BranchList.AddRange(objbranchitm); #endregion //ViewBag.EmpId = id; //EmployeeService objEMP = new EmployeeService(); //string s; //s = objEMP.getEMP(id); //ViewBag.EmpName = s; EmpAllItem objAllItem = new EmpAllItem(); objAllItem.EmployeeItem = objmaster; return(View(objAllItem)); }
public ActionResult Create(EmpAllItem model) { EmployeeService objEmpService = new EmployeeService(); model.EmployeeItem.WorkingStatus = 96; if (model.EmployeeItem.Branchid == null) { model.EmployeeItem.Branchid = 0; } if (model.EmployeeItem != null) { HttpPostedFileBase file = Request.Files["file"]; var fileName = Path.GetFileName(file.FileName); if (fileName != "") { var path = Path.Combine(Server.MapPath("../PhotoUpload"), fileName); file.SaveAs(path); model.EmployeeItem.Photo = fileName; } } string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } model.EmployeeItem.CreatedDate = System.DateTime.Now; model.EmployeeItem.CreatedBy = uid; int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } if (model.EmployeeItem.Compid == null) { model.EmployeeItem.Compid = cid; } int p = objEmpService.Insert(model); return(RedirectToAction("Index", "Employee")); //ModelState.AddModelError("", ""); // return RedirectToAction("Create", "Employee"); }
public ActionResult FillDisCon(int FID) { //string strCompCode = Convert.ToString(Compid); List <EmpAllItem> lstEmp = new List <EmpAllItem>(); EmpAllItem objEmpItem = new EmpAllItem(); EmployeeService objEmp = new EmployeeService(); int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } lstEmp = objEmp.GetALLDetails(FID, cid); objEmpItem.EmployeeALLDetails = new List <EmpAllItem>(); //objBranchItem.ListBranch.Add(new BranchItem { id = 0, BranchName = "--Select Branch--" }); objEmpItem.EmployeeALLDetails.AddRange(lstEmp); //var e = new { BranchItem = objBranchItem.ListBranch, EmployeeItem = objBranchItem.ListBranch }; //return Json(objEmpItem.EmployeeALLDetails, JsonRequestBehavior.AllowGet); return(PartialView("_ListEmp", objEmpItem.EmployeeALLDetails)); }
public ActionResult Edit(EmpAllItem model) { EmployeeItem objmasterp = new EmployeeItem(); EmployeeService objmasterme = new EmployeeService(); HttpPostedFileBase file = Request.Files["file"]; var fileName = Path.GetFileName(file.FileName); if (fileName != "") { var path = Path.Combine(Server.MapPath("/PhotoUpload"), fileName); file.SaveAs(path); model.EmployeeItem.Photo = fileName; } else { //if (fileName == "") //{ if (Session["PhotoId"] != null) { fileName = Session["PhotoId"].ToString(); } // var path = Path.Combine(Server.MapPath("/PhotoUpload"), fileName); // file.SaveAs(path); model.EmployeeItem.Photo = fileName; //} } string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } model.EmployeeItem.UpdatedBy = uid; model.EmployeeItem.UpdatedDate = System.DateTime.Now; objmasterme.Update(model); //return RedirectToAction("Create"); return(RedirectToAction("Index", "Employee")); }
// // GET: /Dashboard/ public ActionResult Index() { // load menu //licence List <EmpHealthItem> lstDlicence = new List <EmpHealthItem>(); EmpAllItem objEmp = new EmpAllItem(); DashboardService objDashboard = new DashboardService(); int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } lstDlicence = objDashboard.GetLicence(cid); objEmp.EmpLicenceItem = new List <EmpHealthItem>(); objEmp.EmpLicenceItem.AddRange(lstDlicence); //Licence30 List <EmpHealthItem> lstDlicence30 = new List <EmpHealthItem>(); //EmpAllItem objEmp30 = new EmpAllItem(); DashboardService objDashboard30 = new DashboardService(); lstDlicence30 = objDashboard.GetLicence30(cid); objEmp.EmpLicenceItem30 = new List <EmpHealthItem>(); objEmp.EmpLicenceItem30.AddRange(lstDlicence30); //Passport List <EmpPassportItem> lstPassport = new List <EmpPassportItem>(); DashboardService objDash = new DashboardService(); lstPassport = objDash.GetPassport(cid); objEmp.EmppassItem = new List <EmpPassportItem>(); objEmp.EmppassItem.AddRange(lstPassport); //Passport30 List <EmpPassportItem> lstPassport30 = new List <EmpPassportItem>(); DashboardService objDash30 = new DashboardService(); lstPassport30 = objDash30.GetPassport30(cid); objEmp.EmppassItem30 = new List <EmpPassportItem>(); objEmp.EmppassItem30.AddRange(lstPassport30); //HealthCard List <EmpHealthItem> lstHealthCard = new List <EmpHealthItem>(); DashboardService objDashHC = new DashboardService(); lstHealthCard = objDashHC.GetHealthCard(cid); objEmp.EmpHealthItem = new List <EmpHealthItem>(); objEmp.EmpHealthItem.AddRange(lstHealthCard); //HealthCard30 List <EmpHealthItem> lstHealthCard30 = new List <EmpHealthItem>(); DashboardService objDashHC30 = new DashboardService(); lstHealthCard30 = objDashHC30.GetHealthCard30(cid); objEmp.EmpHealthItem30 = new List <EmpHealthItem>(); objEmp.EmpHealthItem30.AddRange(lstHealthCard30); //Work Permit(Labour card) List <EmpHealthItem> lstLabourCard = new List <EmpHealthItem>(); DashboardService objLCDB = new DashboardService(); lstLabourCard = objLCDB.GetLabourCard(cid); objEmp.EmpLabourItem = new List <EmpHealthItem>(); objEmp.EmpLabourItem.AddRange(lstLabourCard); //Work Permit(Labour card)30 List <EmpHealthItem> lstLabourCard30 = new List <EmpHealthItem>(); DashboardService objLCDB30 = new DashboardService(); lstLabourCard30 = objLCDB30.GetLabourCard30(cid); objEmp.EmpLabourItem30 = new List <EmpHealthItem>(); objEmp.EmpLabourItem30.AddRange(lstLabourCard30); //Insurance List <EmpInsuranceItem> lstInsu = new List <EmpInsuranceItem>(); DashboardService objInsuDB = new DashboardService(); lstInsu = objInsuDB.getInsu(cid); objEmp.EmpInsuItem = new List <EmpInsuranceItem>(); objEmp.EmpInsuItem.AddRange(lstInsu); //Insurance30 List <EmpInsuranceItem> lstInsu30 = new List <EmpInsuranceItem>(); DashboardService objInsuDB30 = new DashboardService(); lstInsu30 = objInsuDB30.getInsu30(cid); objEmp.EmpInsuItem30 = new List <EmpInsuranceItem>(); objEmp.EmpInsuItem30.AddRange(lstInsu30); //VehicleRegistration List <VehicleItem> lstVehicle = new List <VehicleItem>(); DashboardService objVehicleDB = new DashboardService(); lstVehicle = objVehicleDB.getVehicle(cid); objEmp.ListVehicle = new List <VehicleItem>(); objEmp.ListVehicle.AddRange(lstVehicle); //VehicleRegistration30 List <VehicleItem> lstVehicle30 = new List <VehicleItem>(); DashboardService objVehicleDB30 = new DashboardService(); lstVehicle30 = objVehicleDB30.getVehicle30(cid); objEmp.ListVehicle30 = new List <VehicleItem>(); objEmp.ListVehicle30.AddRange(lstVehicle30); //Increments List <EmpIncrementItem> lstIncrements = new List <EmpIncrementItem>(); DashboardService objIncrementsDB = new DashboardService(); lstIncrements = objIncrementsDB.getIncrement(cid); objEmp.ListIncrement = new List <EmpIncrementItem>(); objEmp.ListIncrement.AddRange(lstIncrements); //Visa List <EmpVisaItem> lstVisa = new List <EmpVisaItem>(); DashboardService objVisaDB = new DashboardService(); lstVisa = objVisaDB.getVisa(cid); objEmp.ListVisa = new List <EmpVisaItem>(); objEmp.ListVisa.AddRange(lstVisa); //Visa30 List <EmpVisaItem> lstVisa30 = new List <EmpVisaItem>(); DashboardService objVisaDB30 = new DashboardService(); lstVisa30 = objVisaDB30.getVisa30(cid); objEmp.ListVisa30 = new List <EmpVisaItem>(); objEmp.ListVisa30.AddRange(lstVisa30); //Emirates List <EmpHealthItem> lstEmirates = new List <EmpHealthItem>(); DashboardService objEmiratesDB = new DashboardService(); lstEmirates = objEmiratesDB.getEmirates(cid); objEmp.ListEmirates = new List <EmpHealthItem>(); objEmp.ListEmirates.AddRange(lstEmirates); //Emirates30 List <EmpHealthItem> lstEmirates30 = new List <EmpHealthItem>(); DashboardService objEmiratesDB30 = new DashboardService(); lstEmirates30 = objVisaDB.getEmirates30(cid); objEmp.ListEmirates30 = new List <EmpHealthItem>(); objEmp.ListEmirates30.AddRange(lstEmirates30); //CompDoc List <TradeLicenseItem> lstCompDoc = new List <TradeLicenseItem>(); DashboardService objService = new DashboardService(); lstCompDoc = objService.getCompDoc(cid); objEmp.ListCompDoc = new List <TradeLicenseItem>(); objEmp.ListCompDoc.AddRange(lstCompDoc); //CompDoc30 List <TradeLicenseItem> lstCompDoc30 = new List <TradeLicenseItem>(); lstCompDoc30 = objService.getCompDoc30(cid); objEmp.ListCompDoc30 = new List <TradeLicenseItem>(); objEmp.ListCompDoc30.AddRange(lstCompDoc30); //Tenancy List <TenancyItem> lstTenancy = new List <TenancyItem>(); lstTenancy = objService.getTenancy(cid); objEmp.ListTenancy = new List <TenancyItem>(); objEmp.ListTenancy.AddRange(lstTenancy); //Tenancy30 List <TenancyItem> lstTenancy30 = new List <TenancyItem>(); lstTenancy30 = objService.getTenancy30(cid); objEmp.ListTenancy30 = new List <TenancyItem>(); objEmp.ListTenancy30.AddRange(lstTenancy30); //ExpContract List <ContractModel> lstContract = new List <ContractModel>(); lstContract = objService.getExpContract(cid); objEmp.ListExpCont = new List <ContractModel>(); objEmp.ListExpCont.AddRange(lstContract); //Contract30 List <ContractModel> lstContract30 = new List <ContractModel>(); lstContract30 = objService.get30Contract(cid); objEmp.List30Cont = new List <ContractModel>(); objEmp.List30Cont.AddRange(lstContract30); //Missing Info //EmpDOB List <EmployeeItem> lstDOB = new List <EmployeeItem>(); DashboardService objDOB = new DashboardService(); lstDOB = objDOB.getEmpDOB(cid); objEmp.ListEmpDOB = new List <EmployeeItem>(); objEmp.ListEmpDOB.AddRange(lstDOB); //EmpBasicSalary List <EmployeeItem> lstBS = new List <EmployeeItem>(); DashboardService objBS = new DashboardService(); lstBS = objBS.getEmpBS(cid); objEmp.ListEmpBS = new List <EmployeeItem>(); objEmp.ListEmpBS.AddRange(lstBS); //EmpPassport List <EmpPassportItem> lstPass = new List <EmpPassportItem>(); DashboardService objPass = new DashboardService(); lstPass = objPass.getEmpPassport(cid); objEmp.ListPass = new List <EmpPassportItem>(); objEmp.ListPass.AddRange(lstPass); //EmpLabour List <EmployeeItem> lstLabour = new List <EmployeeItem>(); DashboardService objLabour = new DashboardService(); lstLabour = objLabour.getLabour(cid); objEmp.ListEmpLabour = new List <EmployeeItem>(); objEmp.ListEmpLabour.AddRange(lstLabour); //EmpVisa List <EmpVisaItem> lstEmpVisa = new List <EmpVisaItem>(); DashboardService objVisa = new DashboardService(); lstEmpVisa = objVisa.getEmpVisa(cid); objEmp.ListEmpVisa = new List <EmpVisaItem>(); objEmp.ListEmpVisa.AddRange(lstEmpVisa); //EmpEID List <EmployeeItem> lstEID = new List <EmployeeItem>(); DashboardService objEID = new DashboardService(); lstEID = objEID.getEmpEID(cid); objEmp.ListEmpEID = new List <EmployeeItem>(); objEmp.ListEmpEID.AddRange(lstEID); return(View(objEmp)); }
//This is the default index controller in which we can return all employees public ActionResult Index(EmpAllItem model) { EmpAllItem objAllItem = new EmpAllItem(); EmployeeService objclsmethod = new EmployeeService(); //int mid = Convert.ToInt32(Request.QueryString["Compid"]); int cid = 0; if (model.EmployeeItem == null) { int id = 0; if (Url.RequestContext.RouteData.Values["id"] != null) { id = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); ViewBag.Empid = id; } if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } List <EmployeeItem> objMaster = objclsmethod.GetALL(cid); List <EmpAllItem> ObjEmpAllItem = objclsmethod.GetALLDetails(0, cid); List <CompanyItem> objCompany = new List <CompanyItem>(); CompanyService objListCompany = new CompanyService(); objCompany = objListCompany.GetALL(); EmployeeItem objEmpItem = new EmployeeItem(); objEmpItem.CompanyList = new List <CompanyItem>(); objEmpItem.CompanyList.AddRange(objCompany); //Added by Kuldip Patel @07-06-2016 #region Bind RDB Working Status List <clsMasterData> lstMasters1 = new List <clsMasterData>(); EmployeeService objclsmethod1 = new EmployeeService(); lstMasters1 = objclsmethod1.GetWorkingStatus(); EmployeeItem objItem = new EmployeeItem(); objEmpItem.listMasterWS = new List <clsMasterData>(); objEmpItem.listMasterWS.AddRange(lstMasters1); #endregion objAllItem.EmployeeItem = objEmpItem; objAllItem.EmployeeALLDetails = new List <EmpAllItem>(); objAllItem.EmployeeALLDetails.AddRange(ObjEmpAllItem); return(View(objAllItem)); } else if (model.EmployeeItem != null) { if (model.EmployeeItem.Compid != null) { int i = Convert.ToInt32(model.EmployeeItem.Compid); List <EmpAllItem> objEmAll = new List <EmpAllItem>(); objEmAll = objclsmethod.GetALLDetails(0, cid); List <CompanyItem> objCompany = new List <CompanyItem>(); CompanyService objListCompany = new CompanyService(); objCompany = objListCompany.GetALL(); EmployeeItem objEmpItem = new EmployeeItem(); objEmpItem.CompanyList = new List <CompanyItem>(); objEmpItem.CompanyList.AddRange(objCompany); //Added by Kuldip Patel @07-06-2016 #region Bind RDB Working Status List <clsMasterData> lstMasters1 = new List <clsMasterData>(); EmployeeService objclsmethod1 = new EmployeeService(); lstMasters1 = objclsmethod1.GetWorkingStatus(); EmployeeItem objItem = new EmployeeItem(); objEmpItem.listMasterWS = new List <clsMasterData>(); objEmpItem.listMasterWS.AddRange(lstMasters1); #endregion objAllItem.EmployeeItem = objEmpItem; objAllItem.EmployeeALLDetails = new List <EmpAllItem>(); objAllItem.EmployeeALLDetails.AddRange(objEmAll); return(View(objAllItem)); } } return(RedirectToAction("Index")); }
//public ActionResult Index(int employeeId) //{ // //Using this parameter we have to use employee id instead of session to remove concurrency conflict because for each update of details route will be lie // // ConterollerName/ActionName/EmployeeId // //Any question? // return new RedirectResult("DashboardController/{EmployeeId}"); //} public ActionResult Create() { // For Bind Company #region Company Bind List <CompanyItem> objCompany = new List <CompanyItem>(); CompanyService objListCompany = new CompanyService(); objCompany = objListCompany.GetALL(); EmployeeItem objEmpItem = new EmployeeItem(); objEmpItem.CompanyList = new List <CompanyItem>(); objEmpItem.CompanyList.AddRange(objCompany); #endregion //For Bind Branch #region Bind Branch List <BranchItem> objbranchitm = new List <BranchItem>(); BranchService objbranchservice = new BranchService(); objbranchitm = objbranchservice.GetAll(); //objEmpItem = new EmployeeItem(); objEmpItem.BranchList = new List <BranchItem>(); objEmpItem.BranchList.AddRange(objbranchitm); EmpAllItem objAllItem = new EmpAllItem(); objAllItem.EmployeeItem = objEmpItem; #endregion //var tuple = new Tuple<EmployeeItem, EmpRelativeItem>(objEmpItem, new EmpRelativeItem()); //For Bind CountryList EmpContactItem objContact = new EmpContactItem(); EmployeeService objServiceEmp = new EmployeeService(); #region Country Bind List <CountryItem> objCountry = new List <CountryItem>(); objServiceEmp = new EmployeeService(); objCountry = objServiceEmp.CountryList(); objContact = new EmpContactItem(); objContact.CountryList = new List <CountryItem>(); objContact.CountryList.AddRange(objCountry); objAllItem.EmpContactItem = objContact; #endregion //bind Jobtitle #region Bind DropDown Jobtitle List <clsMasterData> lstMasters1 = new List <clsMasterData>(); EmployeeService objclsmethod = new EmployeeService(); lstMasters1 = objclsmethod.GetJobTitle(); EmployeeItem objItem = new EmployeeItem(); objAllItem.listMaster = new List <clsMasterData>(); objAllItem.listMaster.AddRange(lstMasters1); #endregion // For bind Relation #region Relation Bind //objContact = new EmpContactItem(); //objServiceEmp = new EmployeeService(); //List<MasterDataItem> objMasterDataListR = new List<MasterDataItem>(); //objMasterDataListR = objServiceEmp.GetMasterData(35); #endregion return(View(objAllItem)); }