示例#1
0
        public async Task <ActionResult> Create(FileUploadViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.ImageUpload != null && model.ImageUpload.ContentLength > 0)
                {
                    VtaDbContext db   = new VtaDbContext();
                    var          file = await db.Files.FindAsync(model.FileId);

                    string extension = Path.GetExtension(model.ImageUpload.FileName);
                    await AzureHelper.CreateAndConfigureAsync();

                    HttpPostedFileBase photoToUpload = model.ImageUpload;
                    string             name          = file.Id + extension;
                    string             url           = await AzureHelper.UploadPhotoAsync(photoToUpload, name);

                    file.SourceUrl       = url;
                    file.IsUploaded      = true;
                    file.ConvertedUrl    = "";
                    file.IsConverted     = false;
                    db.Entry(file).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Files"));
            }
            return(View(model));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Description,ContentId,SerialNo,IsActive,Created,CreatedBy,Modified,ModifiedBy")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Entry(question).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", question.ContentId);
            return(View(question));
        }
示例#3
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Type,LevelId,No,Point,Tags,Created,CreatedBy,Modified,ModifiedBy")] Content content)
        {
            if (ModelState.IsValid)
            {
                db.Entry(content).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.LevelId = new SelectList(db.Levels, "Id", "Name", content.LevelId);
            return(View(content));
        }
        public async Task <ActionResult> Edit(Course course)
        {
            if (ModelState.IsValid)
            {
                course.Modified        = DateTime.Now;
                db.Entry(course).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(course));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,SerialNo,IsAnswer,QuestionId,Created,CreatedBy,Modified,ModifiedBy")] Option option)
        {
            if (ModelState.IsValid)
            {
                db.Entry(option).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Name", option.QuestionId);
            return(View(option));
        }
示例#6
0
        public async Task <ActionResult> Edit(Level level)
        {
            if (ModelState.IsValid)
            {
                db.Entry(level).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", level.CourseId);
            return(View(level));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,ContentId,Name,Url,Tags,Created,CreatedBy,Modified,ModifiedBy")] Website website)
        {
            if (ModelState.IsValid)
            {
                db.Entry(website).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", website.ContentId);
            return(View(website));
        }
示例#8
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,ContentId,Name,Description,SourceUrl,Length,Size,TotalViews,Complexity,SerialNo,IsActive,Tags,Type,Created,CreatedBy,Modified,ModifiedBy")] File file)
        {
            if (ModelState.IsValid)
            {
                db.Entry(file).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", file.ContentId);
            return(View(file));
        }