public async Task <IActionResult> UpdateInstrumentName(int id, [FromBody] int BrokerInstrumentId)
        {
            //if (!ModelState.IsValid)
            //    return BadRequest(ModelState);
            var existingReferenceImage = await context.ScreenerReferenceImages.FindAsync(id);

            if (existingReferenceImage == null)
            {
                return(NotFound());
            }
            if (BrokerInstrumentId == 0)
            {
                existingReferenceImage.BrokerInstrumentId = null;
            }
            else
            {
                existingReferenceImage.BrokerInstrumentId = BrokerInstrumentId;
            }

            await context.SaveChangesAsync();

            if (getCount() == 0)
            {
                BackgroundJob.Schedule <ScreenerParseScheduler>(x => x.Schedule(JobCancellationToken.Null), TimeSpan.FromSeconds(1));
            }

            var result = mapper.Map <ScreenerReferenceImage, ScreenerReferenceImageResource>(existingReferenceImage);

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Post(TraderEntity trader)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Traders.Add(trader);
            await db.SaveChangesAsync();

            return(Created(trader));
        }