public ResultStatus Create(SelectValueContract item) { if (item.IsValid()) { var count = _selectBaseRepository.Count(p => p.Belong == item.Belong && (p.Name == item.Name || p.Code == item.Code)); if (count == 0) { var entity = item.ToEntity(); _selectBaseRepository.Add(entity); return(ResultStatus.Success); } return(ResultStatus.Duplicate); } return(ResultStatus.Failed); }
public static BASE_SELECTE_VALUE_INFO ToEntity(this SelectValueContract source) { if (source == null) { throw new InvalidOperationException("source is null"); } return(new BASE_SELECTE_VALUE_INFO { Id = source.Id, Name = source.Name, Belong = source.Belong, SOrder = source.SOrder, Code = source.Code }); }