Esempio n. 1
0
        public async Task <FileContentResult> UploadImage([FromBody] ImageViewModel model)
        {
            //Depending on if you want the byte array or a memory stream, you can use the below.
            var imageDataByteArray = Convert.FromBase64String(model.ImageData);

            var actor = await _botOMatContext.ErrandActors.FindAsync(model.ActorId);

            if (actor != null)
            {
                actor.Image = imageDataByteArray;
                await _botOMatContext.SaveChangesAsync();
                await NotifyImageUploaded();

                return(File(imageDataByteArray, "image/png"));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Esempio n. 2
0
 private async Task CompleteErrand(ICanPerformErrand actor, Errand errand)
 {
     errand.TimeToComplete = Convert.ToInt32(_stopwatch.ElapsedMilliseconds);
     actor.Errands.Add(errand);
     await _botOMatContext.SaveChangesAsync();
 }