/// <summary> /// RecruitmentLanguageSkillInfo /// </summary> /// <param name="recruitmentLanguageSkill"></param> /// <param name="foreignLanguageDAL"></param> public RecruitmentLanguageSkillInfo(RecruitmentLanguageSkill recruitmentLanguageSkill, ForeignLanguageDAL foreignLanguageDAL) { this.ForeignLanguage = string.Empty; if (recruitmentLanguageSkill.ForeignLanguage != null) { var foreignLanguage = foreignLanguageDAL.GetByID(recruitmentLanguageSkill.ForeignLanguage.LookupId); if (foreignLanguage != null) { this.ForeignLanguage = string.Format("{0}/{1}", foreignLanguage.VietnameseName, foreignLanguage.Name); } } this.Level = recruitmentLanguageSkill.Level != null ? recruitmentLanguageSkill.Level : string.Empty; }
private void SaveLanguageSkills() { try { JavaScriptSerializer seriallizer = new JavaScriptSerializer(); List <RecruitmentLanguageSkillModel> recruitmentLanguageSkillItems = seriallizer.Deserialize <List <RecruitmentLanguageSkillModel> >(hdRecruitmentLanguageSkills.Value); // List<RecruitmentLanguageSkill> recruitmentLanguageSkillItems = new List<RecruitmentLanguageSkill>(); if (recruitmentLanguageSkillItems == null) { recruitmentLanguageSkillItems = new List <RecruitmentLanguageSkillModel>(); } #region Delete List Of Detail Items string queryString = string.Format(@"<Where> <Eq> <FieldRef Name='{0}' LookupId='True' /> <Value Type='Lookup'>{1}</Value> </Eq> </Where>", StringConstant.RecruitmentLanguageSkillsList.Fields.Request, this.CurrentItem.ID); IList <int> ids = null; var currentItems = recruitmentLanguageSkillsDAL.GetByQuery(queryString); if (currentItems != null && currentItems.Count > 0) { ids = new List <int>(); foreach (var item in currentItems) { var existedItem = recruitmentLanguageSkillItems.Where(recruitmentLanguageSkillItem => recruitmentLanguageSkillItem.ID == item.ID).FirstOrDefault(); // Neu khong ton tai => Xoa if (existedItem == null) { ids.Add(item.ID); } } } if (ids != null && ids.Count > 0) { recruitmentLanguageSkillsDAL.DeleteItems(ids); } #endregion foreach (var item in recruitmentLanguageSkillItems) { var newItem = new RecruitmentLanguageSkill { ForeignLanguage = new LookupItem { LookupId = item.ForeignLanguage }, Level = item.Level, Request = new LookupItem { LookupId = this.CurrentItem.ID } }; recruitmentLanguageSkillsDAL.SaveItem(newItem); } } catch (Exception ex) { ULSLogging.LogError(ex); ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentFormUserControl: {ex.Message}"); } }