public async Task <ActionResult <VendorDto> > PostVendorAsync([FromForm] string values, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(values)) { return(BadRequest("Values cannot be null or empty")); } var vendor = new Vendor(); JsonConvert.PopulateObject(values, vendor); await _farmAppContext.AddAsync(vendor, cancellationToken); await _farmAppContext.SaveChangesAsync(cancellationToken); return(Ok(_mapper.Map <VendorDto>(vendor))); }
public async Task <ActionResult <DrugDto> > PostAsync([FromForm] string values, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(values)) { return(BadRequest("Value cannot be null or empty")); } var drug = new Drug(); JsonConvert.PopulateObject(values, drug); await _farmAppContext.AddAsync(drug, cancellationToken); await _farmAppContext.SaveChangesAsync(cancellationToken); return(Ok(_mapper.Map <DrugDto>(drug))); }
public async Task <ActionResult <RegionTypeDto> > PostRegionTypeAsync([FromForm] string values, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(values)) { return(BadRequest("Value cannot be null or empty")); } var regionType = new RegionType(); JsonConvert.PopulateObject(values, regionType); await _farmAppContext.AddAsync(regionType, cancellationToken); await _farmAppContext.SaveChangesAsync(cancellationToken); return(Ok(_mapper.Map <RegionTypeDto>(regionType))); }
public async Task <ActionResult <PharmacyDto> > PostAsync([FromForm] string values, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(values)) { return(BadRequest("Value cannot be null or empty")); } var pharmacy = new Pharmacy(); JsonConvert.PopulateObject(values, pharmacy); if (pharmacy.PharmacyId == 0) { pharmacy.PharmacyId = null; } await _farmAppContext.AddAsync(pharmacy, cancellationToken); await _farmAppContext.SaveChangesAsync(cancellationToken); return(Ok(_mapper.Map <PharmacyDto>(pharmacy))); }