Пример #1
0
        public async Task <JsonResult> Description()
        {
            var record = ((JObject)HttpContext.Items["JSON"]).GetValue("Record").ToObject <Record>();

            record.Path = null;
            try
            {
                using (var db = new RecordDb())
                    if (record.IsPublic)
                    {
                        await db.GetPublic(record, UserR.Id.Value);
                    }
                    else
                    {
                        await db.GetPaid(record, UserR.Id.Value);
                    }
                if (record?.Path != null)
                {
                    record.PhotoPath = null;
                    record.Path      = null;
                    return(new JsonResult(record));
                }
            }
            catch (Exception ex)
            { }
            return(null);
        }
Пример #2
0
        public async Task <FileResult> Liseten()
        {
            var record = ((JObject)HttpContext.Items["JSON"]).GetValue("Record").ToObject <Record>();

            record.Path = null;
            using (var db = new RecordDb())
                if (record.IsPublic)
                {
                    await db.GetPublic(record, UserR.Id.Value);
                }
                else
                {
                    await db.GetPaid(record, UserR.Id.Value);
                }
            if (record?.Path != null)
            {
                FileStream fs = new FileStream(record.Path, FileMode.Open);
                return(File(fs, "application/mp3", record.Name + ".mp3"));
            }
            return(null);
        }