public int Insert(JobMajor ins) { try { db.JobMajors.Add(ins); db.SaveChanges(); return(ins.JobID); } catch (Exception e) { return(-1); } }
public JsonResult CreateAccountInfor(InsertEnterpriseForm model) { var enterprise = new Enterprise(); enterprise.EnterpriseID = model.Id; enterprise.EnterpriseName = model.Name; enterprise.Email = model.Email; enterprise.Mobile = model.Mobile; enterprise.EstablishYear = model.EstablishYear; enterprise.ImageLogo = model.Logo; enterprise.TypeOfEnterprise = model.Type; enterprise.Status = false; enterprise.EnterpriseSize = model.Size; var checkInsEnterprise = new EnterpriseDao().Insert(enterprise); var ret = true; foreach (var item in model.ListArea) { if (!ret) { break; } var enterpriseArea = new EnterpriseArea(); enterpriseArea.AreaID = item; enterpriseArea.EnterpriseId = model.Id; var check = new EnterpriseAreaDao().Insert(enterpriseArea); if (!check) { ret = false; } } if (model.ListJobImp != null) { foreach (var item in model.ListJobImp) { if (!ret) { break; } var enterpriseJob = new EnterpriseJob(); enterpriseJob.EnterpriseID = model.Id; enterpriseJob.JobId = item; enterpriseJob.JobIdParent = null; enterpriseJob.Important = true; var check = new EnterpriseJobDao().Insert(enterpriseJob); if (!check) { ret = false; } } } if (model.ListJobSub != null) { foreach (var item in model.ListJobSub) { if (!ret) { break; } var enterpriseJob = new EnterpriseJob(); enterpriseJob.EnterpriseID = model.Id; enterpriseJob.JobId = item; enterpriseJob.JobIdParent = null; enterpriseJob.Important = false; var check = new EnterpriseJobDao().Insert(enterpriseJob); if (!check) { ret = false; } } } if (model.NewJobImp != null) { foreach (var item in model.NewJobImp) { if (!ret) { break; } var newJob = new JobMajor(); newJob.JobName = item; newJob.Status = false; var checkJob = new JobMajorDao().Insert(newJob); if (checkJob == -1) { ret = false; continue; } var enterpriseJob = new EnterpriseJob(); enterpriseJob.EnterpriseID = model.Id; enterpriseJob.JobId = checkJob; enterpriseJob.JobIdParent = null; enterpriseJob.Important = true; var check = new EnterpriseJobDao().Insert(enterpriseJob); if (!check) { ret = false; } } } if (model.NewJobSub != null) { foreach (var item in model.NewJobSub) { if (!ret) { break; } var newJob = new JobMajor(); newJob.JobName = item; newJob.Status = false; var checkJob = new JobMajorDao().Insert(newJob); if (checkJob == -1) { ret = false; continue; } var enterpriseJob = new EnterpriseJob(); enterpriseJob.EnterpriseID = model.Id; enterpriseJob.JobId = checkJob; enterpriseJob.JobIdParent = null; enterpriseJob.Important = false; var check = new EnterpriseJobDao().Insert(enterpriseJob); if (!check) { ret = false; } } } if (!ret) { return(Json(new { status = false })); } return(Json(new { status = true })); }