Example #1
0
        public ActionResult FormAcara(IsianEvent isian)
        {
            if (ModelState.IsValid)
            {
                DataEventEntities Data  = new DataEventEntities();
                Event             param = new Event();

                /* upload file */
                var    file      = isian.ImageFile;
                byte[] imagebyte = null;
                file.SaveAs(Server.MapPath("~/Upload/" + file.FileName));
                BinaryReader reader = new BinaryReader(file.InputStream);
                imagebyte      = reader.ReadBytes(file.ContentLength);
                param.namaFile = file.FileName;
                param.pathFile = "~/Upload/" + file.FileName;
                param.byteFIle = imagebyte;

                /*insert table */
                param.nama_event  = isian.Nama;
                param.jenis_event = isian.Jenis;
                param.waktu_event = isian.Waktu;
                param.deskripsi   = isian.Deskripsi;

                Data.Event.Add(param);
                Data.SaveChanges();
                return(View("Sukses", isian));
            }
            else
            {
                return(View());
            }
        }
Example #2
0
        public ActionResult Delete(int id)
        {
            DataEventEntities db = new DataEventEntities();
            var idEvent          = (from item in db.Event where item.Id_event == id select item).First();

            db.Event.Remove(idEvent);
            db.SaveChanges();
            var list = db.Event.ToList();

            return(View("DataEvent", list));
        }
Example #3
0
        public ActionResult Edit(Event Event)
        {
            DataEventEntities db = new DataEventEntities();
            var idEvent          = (from item in db.Event where item.Id_event == Event.Id_event select item).First();

            idEvent.nama_event  = Event.nama_event;
            idEvent.jenis_event = Event.jenis_event;
            idEvent.waktu_event = Event.waktu_event;
            idEvent.deskripsi   = Event.deskripsi;
            db.SaveChanges();
            var list = db.Event.ToList();

            return(View("DataEvent", list));
        }