/// <summary> /// Thêm mới CatType /// </summary> /// <param name="cat"></param> /// <param name="userName"></param> /// <returns></returns> public object AddNewCatType(MNG_CatType cat, string userName) { try { #region HANDLER string[] value = CRMHelper.RemoveUnicode(cat.CatTypeName).Split(' '); string result = string.Empty; for (int i = 0; i < value.Count(); i++) { result += value[i].Substring(0, 1); } if (result.Length > 5) { result = result.Substring(0, 5); } if (!dbContext.MNG_Category.Any(x => x.CatTypeCode == result)) { cat.IsDeleted = false; cat.CatTypeCode = result; dbContext.MNG_CatType.Add(cat); dbContext.SaveChanges(); } else { return(MP_AjaxError.Exits); } return(MP_AjaxError.OK); #endregion } catch (System.Exception ex) { return(ex.Message); } }