Пример #1
0
        public ActionResult Create(QuestionViewModel model)
        {
            HttpPostedFileBase file = model.imgurl;
            var path = "";

            if (file != null)
            {
                if (file.ContentLength > 0)
                {
                    // Untuk Mengecek apakah file berformat gambar
                    if ((Path.GetExtension(file.FileName).ToLower() == ".jpg") || (Path.GetExtension(file.FileName).ToLower() == ".png") || (Path.GetExtension(file.FileName).ToLower() == ".gif") || (Path.GetExtension(file.FileName).ToLower() == ".jpeg"))
                    {
                        path = Path.Combine(Server.MapPath("~/Images"), file.FileName);
                        file.SaveAs(path);
                    }
                }
                model.imageUrl = file.FileName;
            }

            ResponseResult result = QuestionRepo.Update(model);

            return(Json(new
            {
                success = result.Success,
                message = result.ErrorMessage,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult Delete(QuestionViewModel model)
        {
            var userid = (long)Session["userid"];
            ResponResultViewModel result = QuestionRepo.Update(model, userid);

            return(Json(new
            {
                success = result.Success,
                message = result.Message,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }