Example #1
0
        public async Task <IActionResult> Uploadfile(int UserId, int DataId, int DatasetId, int LangId, int DomainId, IFormFile file)
        {
            DatasetSubcategoryMapping datasetSubcategoryMapping = _context.DatasetSubcategoryMapping.Find(DatasetId);
            SubCategories             destTableName             = _context.SubCategories.Find(datasetSubcategoryMapping.DestinationSubcategoryId);

            if (destTableName.Name == "TextSpeech")
            {
                try
                {
                    using (var stream = new MemoryStream())
                    {
                        await file.CopyToAsync(stream);

                        TextSpeech textSpeech = new TextSpeech();
                        textSpeech.UserId     = UserId;
                        textSpeech.Age        = _context.UserInfo.Find(UserId).Age;
                        textSpeech.Gender     = _context.UserInfo.Find(UserId).Gender;
                        textSpeech.DataId     = DataId;
                        textSpeech.LangId     = LangId;
                        textSpeech.DomainId   = DomainId;
                        textSpeech.OutputData = stream.ToArray();
                        textSpeech.DatasetId  = DatasetId;
                        textSpeech.AddedOn    = DateTime.Now;
                        textSpeech.TotalValidationUsersCount = 0;

                        TextToSpeech.TextSpeech.Add(textSpeech);
                        TextToSpeech.SaveChanges();
                        jsonResponse.IsSuccessful = true;
                        jsonResponse.Response     = "File Uploaded Successfully";
                        return(Ok(jsonResponse));
                    }
                }
                catch (Exception)
                {
                    jsonResponse.IsSuccessful = false;
                    jsonResponse.Response     = "Internal Exception";
                    return(BadRequest(jsonResponse));
                }
            }
            jsonResponse.IsSuccessful = false;
            jsonResponse.Response     = "Table Not Found.";
            return(NotFound(jsonResponse));
        }