public Response <bool> UpdateAttribute(AttributeEditModel model) { if (model.Abbreviation.Equals("")) { return(new Response <bool>(false, (int)ErrorEnum.Aplied, "Сокращенное название обязательно для заполнения")); } if (model.Name.Equals("")) { return(new Response <bool>(false, (int)ErrorEnum.Aplied, "Наименование обязательно для заполнения")); } var currentEntity = model.Id == null ? new DictionaryAttribute { Id = Guid.NewGuid() } : _dictionaryAttrContext.GetById((Guid)model.Id); currentEntity.Abbreviation = model.Abbreviation.ToUpper().Replace(" ", "_"); currentEntity.AttributeFunction = AttributeFunction.GetFunction(model.AttributeFunction); currentEntity.AttributeTypeId = model.AttributeTypeId; currentEntity.Name = model.Name; var transaction = _dictionaryAttrContext.StartTransaction(); _dictionaryAttrContext.Upsert(currentEntity); transaction.Commit(); return(new Response <bool>()); }
public Response <AttributeEditModel> GetAttributeEditModel(Guid attributeId) { if (attributeId.Equals(Guid.Empty)) { return(new Response <AttributeEditModel>(null, (int)ErrorEnum.NotFound, "Запись не найдена")); } var entity = _dictionaryAttrContext.GetById(attributeId); return(new Response <AttributeEditModel>(new AttributeEditModel { Id = entity.Id, Name = entity.Name, AttributeTypeId = entity.AttributeTypeId, Abbreviation = entity.Abbreviation, AttributeFunction = AttributeFunction.GetId(entity.AttributeFunction) })); }
public Response <List <ComboListModel> > AttributeFunctionList(Request <bool> req) { return(new Response <List <ComboListModel> >(AttributeFunction.GetList())); }