public bool Insert(VanderInsertDTO DTO) { bool result = false; var List = new List <Tags>(); if (DTO.Tags != null && DTO.Tags.Count > 0) { foreach (var item in DTO.Tags) { Tags tags = new Tags(); tags.Name = item.Name; tags.Family = item.Family; tags.Address = item.Address; tags.PhoneNumber = item.PhoneNumber; tags.PhoneMobile = item.PhoneMobile; List.Add(tags); } } var vender = new Vender() { Name = DTO.Name, Title = DTO.Title, Date = DTO.Date, Tags = List }; int inserted = _repository.Insert(vender); if (inserted > 0) { result = true; } return(result); }
public IActionResult Insert([FromBody] VanderInsertDTO DTO) { var result = VanderService.Insert(DTO); if (result == true) { return(Ok()); } else { throw new Exception(); } }