public void ParseType(IEntity <TKey> entity) { var model = entity.GetType(); var joha = model.GetCustomAttribute <JohaAttribute>(); TraficcModel request = new TraficcModel(); request.Id = model.GUID; //.ToString(); request.ProjectName = _project; request.EntityModel = joha?.Name ?? model.Name; request.GetFields = new List <Field>(); foreach (var i in model.GetProperties()) { var key = LangState.TT(i); if (key.Value != null) { request.GetFields.Add(new Field() { Name = key.Key, Type = key.Value, Value = "" }); } } var rest = new RestRequest("/Modal/Add", Method.POST); rest.AddJsonBody(request); var result = _client.Execute(rest); }
public async Task <ResponseData> Add([FromBody] TraficcModel model) { try { var project = State.State.LangProject.Projects.FirstOrDefault(m => m.Name == model.ProjectName); bool isUpdate = false; if (project == null) { project = new LangEntity.Project.Projects() { Id = model.Id, Name = model.ProjectName }; isUpdate = true; States.LangProject.Projects.Add(project); } var entity = project.Entitys.FirstOrDefault(m => m.Id == model.Id); if (entity == null) { isUpdate = true; entity = new LangEntity.Project.Entity(); entity.Id = model.Id; entity.Name = model.EntityModel; entity.GetFields = model.GetFields; project.Entitys.Add(entity); } if (isUpdate) { _project.Update(States.LangProject); } return(null); } catch (Exception ext) { } return(null); }