public async Task <Result <LocationView> > AddDescription([FromForm] DescriptionRequestModel model) { var result = new Result <LocationView>(); try { var addDescriptionqQery = new AddLocationDescriptionCommand(model.Location, model.Description); _mediator.Execute(addDescriptionqQery); var getLocationQuery = new GetLocationQuery(model.Location); var location = _mediator.Execute(getLocationQuery); result.Data = _mapper.Map <LocationView>(location); } catch (Exception e) { result.Error = e.Message; result.IsSuccess = false; } finally { _logger.LogInformation($"Location retrieved."); } return(result); }
public async Task <ActionResult <IEnumerable <LithologySectionInfoModel> > > GetDescriptionsBySection([FromQuery] DescriptionRequestModel requestParameters) { try { var records = await _repo.Sections.Where(x => requestParameters.SectionTextIDsCollection.Contains(x.SectionTextId)) .Include(x => x.LithologicDescriptions) .ThenInclude(x => x.LithologyTable) .SelectMany(x => x.LithologicDescriptions) .Select(x => new LithologySectionInfoModel(x.LithologyTable, x.SectionInfo)) .ToListAsync(); return(records); } catch (Exception) { throw; } }
public async Task <ActionResult <IEnumerable <LithologySectionInfoModel> > > GetLithologiesBySection([FromBody] DescriptionRequestModel request) { var records = await _repo.Sections.Where(x => request.SectionTextIDsCollection.Contains(x.SectionTextId)) .Include(x => x.LithologicDescriptions) .ThenInclude(x => x.LithologyTable) .SelectMany(x => x.LithologicDescriptions) .Select(x => new LithologySectionInfoModel(x.LithologyTable, x.SectionInfo)) .ToListAsync(); return(records); }
public async Task <ActionResult <IEnumerable <LithologySectionInfoModel> > > GetDescriptions([FromQuery] DescriptionRequestModel request) { //https://localhost:44389/api/LithologyTables/GetDescriptions?Expeditions=369&Holes=B,C&Prefices=clayey try { var records = await _repo.Sections.WhereIf(request.ExpeditionsCollection.Count != 0, x => request.ExpeditionsCollection.Contains(x.Expedition)) .WhereIf(request.SitesCollection.Count != 0, x => request.SitesCollection.Contains(x.Site)) .WhereIf(request.HolesCollection.Count != 0, x => request.HolesCollection.Contains(x.Hole)) .WhereIf(request.CoresCollection.Count != 0, x => request.CoresCollection.Contains(x.Core)) .WhereIf(request.CoreTypesCollection.Count != 0, x => request.CoreTypesCollection.Contains(x.Type)) .Include(x => x.LithologicDescriptions) .ThenInclude(x => x.LithologyTable) .SelectMany(x => x.LithologicDescriptions) .WhereIf(request.PreficesCollection.Count != 0, x => request.PreficesCollection.Contains(x.LithologyTable.PrefixLithology)) .WhereIf(request.PrincipalsCollection.Count != 0, x => request.PrincipalsCollection.Contains(x.LithologyTable.PrincipalLithology)) .WhereIf(request.SufficesCollection.Count != 0, x => request.SufficesCollection.Contains(x.LithologyTable.SuffixLithology)) .Select(x => new LithologySectionInfoModel(x.LithologyTable, x.SectionInfo)) .ToListAsync(); return(records); } catch (Exception) { throw; } }