Ejemplo n.º 1
0
        public async Task <IActionResult> Upload()
        {
            try
            {
                var file = Request.Form.Files[0];

                if (file.Length > 0 && file.ContentType.Contains("image"))
                {
                    using (var stream = new MemoryStream())
                    {
                        file.CopyTo(stream);
                        var bytes = stream.ToArray();
                        var image = new MongoImage
                        {
                            Data     = bytes,
                            FileType = file.ContentType
                        };
                        var img = await cont.Create(image);

                        return(Ok(img._id.ToString()));
                    }
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error"));
            }
        }
 public async Task <IActionResult> Post([FromBody] SearchParameter value)
 {
     return(Ok(await cont.Create(value)));
 }
Ejemplo n.º 3
0
 public async Task <IActionResult> Post([FromBody] Role value)
 {
     return(Ok(await cont.Create(value)));
 }
Ejemplo n.º 4
0
 public async Task <IActionResult> Post([FromBody] SystemSetting value)
 {
     return(Ok(await cont.Create(value)));
 }