Пример #1
0
        public async Task <ActionResult> Edit(AviContentd avicontentd, HttpPostedFileBase file)
        {
            if (avicontentd.MID != 0 && file != null)
            {
                // var filename = file.FileName;                    //Path.GetFileName(name);
                var ext = Path.GetExtension(file.FileName);

                Stream       fs       = file.InputStream;
                BinaryReader br       = new BinaryReader(fs);
                byte[]       filedata = br.ReadBytes((Int32)fs.Length);


                avicontentd.AVIContent  = filedata;
                avicontentd.ContentType = ext.ToString();

                try
                {
                    db.Entry(avicontentd).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch (Exception mx)
                {
                    return(Content(mx.Message));
                }
            }

            return(View(avicontentd));
        }
Пример #2
0
        public async Task <ActionResult> Create(AviContentd avicontentd, HttpPostedFileBase file)
        {
            if (avicontentd.MID != 0 && file != null)
            {
                // var filename = file.FileName;                    //Path.GetFileName(name);
                var ext = Path.GetExtension(file.FileName);

                Stream       fs       = file.InputStream;
                BinaryReader br       = new BinaryReader(fs);
                byte[]       filedata = br.ReadBytes((Int32)fs.Length);

                // avicontentd.ContentName = file.FileName;
                avicontentd.AVIContent  = filedata;
                avicontentd.ContentType = ext.ToString();
                db.Avicontetds.Add(avicontentd);
                try
                {
                    await db.SaveChangesAsync();

                    variable.InitResult = avicontentd.ID;

                    //now update Contentd.AviContent=avicontentd.ID in RowID=2
                    // UpdateAviContentd(avicontentd.MID, avicontentd.ID);

                    return(RedirectToAction("Index"));
                }

                catch (Exception mx)
                {
                    return(Content(mx.Message));
                }
            }

            return(View(avicontentd));
        }
Пример #3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            AviContentd avicontentd = await db.Avicontetds.FindAsync(id);

            db.Avicontetds.Remove(avicontentd);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #4
0
        // GET: /AviContentd/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AviContentd avicontentd = await db.Avicontetds.FindAsync(id);

            if (avicontentd == null)
            {
                return(HttpNotFound());
            }
            return(View(avicontentd));
        }
Пример #5
0
        //public void Audio(int id=0)
        //{
        //    AviContentd content = db.Avicontetds.Find(id);
        //    byte[] bt = content.AVIContent;
        //    Response.Clear();
        //    Response.Buffer = true;
        //    Response.ContentType = "audio/" + content.ContentType;
        //    Response.BinaryWrite(bt);
        //    Response.End();


        //}

        /// <summary>
        /// return audio file to play
        /// </summary>

        public ActionResult PlayAudio(int id = 0)
        {
            AviContentd content = db.Avicontetds.Find(id);

            if (content != null)
            {
                byte[] bt = content.AVIContent;
                return(File(bt, "audio/mpeg", "callrecording.mp3"));

                // return File(content.AVIContent, "audio/" + content.ContentType);
            }
            else
            {
                return(null);
            }
        }