private void ValidateDissertationSource(DissertationSource source, string userEmail = null) { if (!string.IsNullOrEmpty(source.ScientificDegreeName) && !ScientificDegrees.ScientificDegreeNames.Keys.Contains(source.ScientificDegreeName)) { throw new BadRequestException("Invalid scientific degree name!"); } if (!string.IsNullOrEmpty(source.ScientificDegreeSpecialty) && !ScientificDegrees.ScientificDegreeSpecialties.Keys.Contains(source.ScientificDegreeSpecialty)) { throw new BadRequestException("Invalid scientific degree specialty!"); } }
private async Task <string> CreateDissertationSourceAsync(DissertationSource source, string userEmail = null) { var dissertationSource = source as DissertationSource; ValidateDissertationSource(dissertationSource); var placeOfPublication = string.IsNullOrEmpty(dissertationSource.PlaceOfPublication) ? string.Empty : $" - {dissertationSource.PlaceOfPublication}"; var yearOfPublication = dissertationSource.YearOfPublication == null ? string.Empty : $", {dissertationSource.YearOfPublication}"; var numberOfPages = dissertationSource.NumberOfPages == null ? string.Empty : $". - {dissertationSource.NumberOfPages} с"; var content = $"{dissertationSource.ParseAuthor()}{dissertationSource.WorkName}{dissertationSource.GetScientificDegree()}{dissertationSource.GetSpecialty()}" + $"{dissertationSource.ParseAllAuthors()}{placeOfPublication}{yearOfPublication}{numberOfPages}."; var newSource = new SourceRecord { Content = content, Type = dissertationSource.Type }; if (!string.IsNullOrEmpty(userEmail)) { await SaveSourceAsync(newSource, userEmail); } return(content); }
public async Task <IActionResult> CreateDissertationSource(DissertationSource source, string email) { var content = await sourceService.CreateSourceAsync(source, email); return(Ok(content)); }