public ActionResult Edit(int id, t_wilayah wilayah) { if (ModelState.IsValid) { using (db) { t_wilayah t_wilayah = db.t_wilayah.Find(id); t_wilayah.geo_location = wilayah.geo_location; t_wilayah.parent_id = wilayah.parent_id; t_wilayah.web_url = wilayah.web_url; t_wilayah.wil_address = wilayah.wil_address; t_wilayah.wil_name = wilayah.wil_name; t_wilayah.wil_phone = wilayah.wil_phone; t_wilayah.wil_type = "Kelurahan"; t_wilayah.wil_email = wilayah.wil_email; db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.parent_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); return(View(wilayah)); } }
public ActionResult Delete(int id = 0) { t_csr_activity t_csr_activity = db.t_csr_activity.Find(id); db.t_csr_activity.Remove(t_csr_activity); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { t_download t_download = db.t_download.Find(id); db.t_download.Remove(t_download); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /admin/album/Delete/5 public ActionResult Delete(int id = 0) { t_album t_album = db.t_album.Find(id); db.t_album.Remove(t_album); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(long id = 0) { t_volunteer t_volunteer = db.t_volunteer.Find(id); db.t_volunteer.Remove(t_volunteer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { t_organisasi t_organisasi = db.t_organisasi.Find(id); db.t_organisasi.Remove(t_organisasi); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { t_csr_ph t_csr_ph = db.t_csr_ph.Find(id); db.t_csr_ph.Remove(t_csr_ph); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { t_bidang t_bidang = db.t_bidang.Find(id); db.t_bidang.Remove(t_bidang); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { t_kegiatan t_kegiatan = db.t_kegiatan.Find(id); db.t_kegiatan.Remove(t_kegiatan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditFoto(int id, admin.Models.FotoAdmin fotoAdmin) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var ada = (from table in db.t_file where table.user_id == id && table.file_category == "FotoUser" select table.file_id).FirstOrDefault(); ViewBag.file = ada; if (fotoAdmin.foto != null) { if (fotoAdmin.foto.ContentLength < 2048000) { var fileName = Path.GetFileName(fotoAdmin.foto.FileName); var ex = Path.GetExtension(fileName); if (ex == ".jpg") { var path = Path.Combine(Server.MapPath("~/Content/Image"), fileName); fotoAdmin.foto.SaveAs(path); var createFile = db.t_file.Create(); createFile.file_category = "FotoUser"; createFile.file_location = path; createFile.file_name = fileName; createFile.file_title = fileName; createFile.file_url = "~/Content/Image/" + fileName; createFile.mime_type = ex; createFile.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); db.t_file.Add(createFile); db.SaveChanges(); if (ViewBag.file != 0) { var hapusFoto = db.t_file.Find(ada); db.t_file.Remove(hapusFoto); db.SaveChanges(); } return(RedirectToAction("Details")); } else { ModelState.AddModelError("", "Foto harus berformat (.jpg)"); return(View(fotoAdmin)); } } else { ModelState.AddModelError("", "Ukuran foto tidak boleh lebih dari 2 MB"); return(View(fotoAdmin)); } } } } return(View(fotoAdmin)); }
public ActionResult Registration(Models.adminModel admin) { if (ModelState.IsValid) { if (admin.password == admin.retype_password) { var user = db.users.FirstOrDefault(u => u.username == admin.username); if (user == null) { using (db) { var crypto = new SimpleCrypto.PBKDF2(); var enkripPassword = crypto.Compute(admin.password); var create = db.users.Create(); var roles = db.detail_roles.Create(); create.username = admin.username; create.user_password = enkripPassword; create.user_passwordsalt = crypto.Salt; create.nama = admin.nama; create.hp = admin.hp; create.email = admin.email; create.alamat = admin.alamat; create.tanggal = DateTime.Now; db.users.Add(create); db.SaveChanges(); roles.id_roles = admin.id_roles; roles.id_user = (from table in db.users where table.username == admin.username select table.id_user).FirstOrDefault(); db.detail_roles.Add(roles); db.SaveChanges(); return(RedirectToAction("Index", "admin")); } } else { ViewBag.role = new SelectList(db.roles.ToList(), "id_roles", "roles"); ViewBag.errorUsername = '******'; return(View(admin)); } } else { ViewBag.role = new SelectList(db.roles.ToList(), "id_roles", "roles"); ViewBag.errorPassword = '******'; return(View(admin)); } } else { ViewBag.role = new SelectList(db.roles.ToList(), "id_roles", "roles"); ViewBag.error = 'y'; return(View(admin)); } }
public ActionResult Edit(t_wilayah t_wilayah) { if (ModelState.IsValid) { db.Entry(t_wilayah).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(t_wilayah)); }
public ActionResult Create(user user) { if (ModelState.IsValid) { db.users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit(t_kesejahteraan t_kesejahteraan) { if (ModelState.IsValid) { db.Entry(t_kesejahteraan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.satuan = new SelectList(db.t_satuan.ToList(), "id_satuan", "satuan"); return(View(t_kesejahteraan)); } }
public ActionResult Create(t_wilayah t_wilayah) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_wilayah.Create(); create.geo_location = t_wilayah.geo_location; create.parent_id = t_wilayah.parent_id; create.web_url = t_wilayah.web_url; create.wil_address = t_wilayah.wil_address; create.wil_name = t_wilayah.wil_name; create.wil_phone = t_wilayah.wil_phone; create.wil_type = "Kelurahan"; create.wil_email = t_wilayah.wil_email; db.t_wilayah.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.parent_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); return(View(t_wilayah)); } }
public ActionResult Edit(int id, t_volunteer volunteer) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { t_volunteer t_volunteer = db.t_volunteer.Find(id); t_volunteer.vol_card_id = volunteer.vol_card_id; t_volunteer.vol_name = volunteer.vol_name; t_volunteer.vol_phone = volunteer.vol_phone; t_volunteer.vol_address = volunteer.vol_address; t_volunteer.vol_occupation = volunteer.vol_occupation; t_volunteer.vol_email = volunteer.vol_email; t_volunteer.kegiatan_id = volunteer.kegiatan_id; db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.kegiatan = new SelectList((from table in db.t_kegiatan select table).ToList(), "kegiatan_id", "kegiatan_nama"); return(View(volunteer)); } }
public ActionResult Create(t_volunteer t_volunteer) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_volunteer.Create(); create.vol_card_id = t_volunteer.vol_card_id; create.vol_name = t_volunteer.vol_name; create.vol_phone = t_volunteer.vol_phone; create.vol_address = t_volunteer.vol_address; create.vol_occupation = t_volunteer.vol_occupation; create.vol_email = t_volunteer.vol_email; create.kegiatan_id = t_volunteer.kegiatan_id; db.t_volunteer.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.kegiatan = new SelectList((from table in db.t_kegiatan select table).ToList(), "kegiatan_id", "kegiatan_nama"); return(View(t_volunteer)); } }
public ActionResult Index(admin.Models.Upload upload) { if (upload.file.ContentLength > 0) { var fileName = Path.GetFileName(upload.file.FileName); var ext = Path.GetExtension(upload.file.ContentType.ToString()); var path = Path.Combine(Server.MapPath("~/Areas"), fileName); upload.file.SaveAs(path); using (db) { var create = db.t_file.Create(); create.file_category = "0"; create.file_location = path; create.file_name = fileName; create.file_parent = 0; create.file_title = fileName; create.file_url = "~/Areas/" + fileName; create.mime_type = ext; create.user_id = 3; db.t_file.Add(create); db.SaveChanges(); } } return(RedirectToAction("Index")); }
public ActionResult Create(t_kegiatan t_kegiatan) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_kegiatan.Create(); create.user_id = db.users.FirstOrDefault(u => u.username == User.Identity.Name).id_user; create.wilayah_id = t_kegiatan.wilayah_id; create.kegiatan_nama = t_kegiatan.kegiatan_nama; create.kegiatan_deskripsi = t_kegiatan.kegiatan_deskripsi; create.kegiatan_tgl_update = DateTime.Now; create.kegiatan_tgl_acara = t_kegiatan.kegiatan_tgl_acara; db.t_kegiatan.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.wilayah_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); return(View(t_kegiatan)); } }
public ActionResult Create(t_kesejahteraan t_kesejahteraan) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_kesejahteraan.Create(); create.ks_name = t_kesejahteraan.ks_name; create.ks_jumlah = t_kesejahteraan.ks_jumlah; create.ks_type = "PSKS"; create.ks_satuan = t_kesejahteraan.ks_satuan; create.ks_date = DateTime.Now; create.ks_year = t_kesejahteraan.ks_year; db.t_kesejahteraan.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.satuan = new SelectList(db.t_satuan.ToList(), "id_satuan", "satuan"); return(View(t_kesejahteraan)); } }
public ActionResult Create(t_wilayah t_wilayah) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_wilayah.Create(); create.geo_location = t_wilayah.geo_location; create.parent_id = 0; create.web_url = t_wilayah.web_url; create.wil_address = t_wilayah.wil_address; create.wil_name = t_wilayah.wil_name; create.wil_phone = t_wilayah.wil_phone; create.wil_type = "Kecamatan"; create.wil_email = t_wilayah.wil_email; db.t_wilayah.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_wilayah)); }
public ActionResult Create(admin.Models.FotoCreate t_dokumentasi) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_dokumentasi.Create(); create.album_id = t_dokumentasi.album_id; create.dokumentasi_date = DateTime.Now; create.dokumentasi_title = t_dokumentasi.dokumentasi_title; create.dokumentasi_type = "video"; if (t_dokumentasi.dokumentasi_path != null) { if (t_dokumentasi.dokumentasi_path.ContentLength < 102400000) { var fileName = Path.GetFileName(t_dokumentasi.dokumentasi_path.FileName); var ex = Path.GetExtension(fileName); if (ex == ".mp4") { var path = Path.Combine(Server.MapPath("~/Content/Video"), fileName); t_dokumentasi.dokumentasi_path.SaveAs(path); create.dokumentasi_path = "~/Content/Video/" + fileName; } else { ModelState.AddModelError("", "Video harus berformat (MP4)"); ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(t_dokumentasi)); } } else { ModelState.AddModelError("", "Ukuran video tidak boleh lebih dari 100 MB"); ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(t_dokumentasi)); } } else { ModelState.AddModelError("", "Video harus diisi"); ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(t_dokumentasi)); } db.t_dokumentasi.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(t_dokumentasi)); } }
public ActionResult Edit(long id, t_news_category t_news_category) { if (ModelState.IsValid) { t_news_category news_category = db.t_news_category.Find(id); using (db) { news_category.category_date = DateTime.Now; news_category.category_title = t_news_category.category_title; news_category.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_news_category)); }
public ActionResult Create(admin.Models.DownloadCreate t_download) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_download.Create(); create.download_date = DateTime.Now; create.download_desc = t_download.download_desc; create.download_title = t_download.download_title; create.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); if (t_download.dokumen != null) { if (t_download.dokumen.ContentLength < 3048000) { var fileName = Path.GetFileName(t_download.dokumen.FileName); var ex = Path.GetExtension(fileName); if (ex == ".pdf" || ex == ".xls" || ex == ".xlsx" || ex == ".doc" || ex == ".docx" || ex == ".ppt" || ex == ".pptx") { var path = Path.Combine(Server.MapPath("~/Content/Document"), fileName); t_download.dokumen.SaveAs(path); create.download_path = "~/Content/Document/" + fileName; } else { ModelState.AddModelError("", "File harus berformat (.pdf/.ppt/.pptx/.xls/.xlsx/.doc/.docx)"); return(View(t_download)); } } else { ModelState.AddModelError("", "Ukuran file tidak boleh lebih dari 3 MB"); return(View(t_download)); } } else { ModelState.AddModelError("", "File harus diisi"); return(View(t_download)); } db.t_download.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_download)); }
public ActionResult Create(t_donatur t_donatur) { if (ModelState.IsValid) { db.t_donatur.Add(t_donatur); db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.bencana = new SelectList( (from table in db.t_report join table2 in db.t_wilayah on table.wil_id equals table2.wil_id select new { table.report_id, table2.wil_name }).ToList(), "report_id", "wil_name"); return(View(t_donatur)); } }
public ActionResult Edit(int id, admin.Models.FotoCreate dokumentasi) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { t_dokumentasi t_dokumentasi = db.t_dokumentasi.Find(id); t_dokumentasi.album_id = dokumentasi.album_id; t_dokumentasi.dokumentasi_date = DateTime.Now; t_dokumentasi.dokumentasi_title = dokumentasi.dokumentasi_title; if (dokumentasi.dokumentasi_path != null) { if (dokumentasi.dokumentasi_path.ContentLength < 2048000) { var fileName = Path.GetFileName(dokumentasi.dokumentasi_path.FileName); var ex = Path.GetExtension(fileName); if (ex == ".jpg") { var path = Path.Combine(Server.MapPath("~/Content/Image"), fileName); dokumentasi.dokumentasi_path.SaveAs(path); t_dokumentasi.dokumentasi_path = "~/Content/Image/" + fileName; } else { ModelState.AddModelError("", "Foto harus berformat (Jpg)"); ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(dokumentasi)); } } else { ModelState.AddModelError("", "Ukuran foto tidak boleh lebih dari 2 MB"); ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(dokumentasi)); } } db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.album_id = new SelectList(db.t_album.ToList(), "album_id", "album_title"); return(View(dokumentasi)); } }
public ActionResult Create(admin.Models.organisasiCreate t_organisasi) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_organisasi.Create(); create.t_nama = t_organisasi.t_nama; create.t_jabatan = t_organisasi.t_jabatan; if (t_organisasi.t_path != null) { if (t_organisasi.t_path.ContentLength < 2048000) { var fileName = Path.GetFileName(t_organisasi.t_path.FileName); var ex = Path.GetExtension(fileName); if (ex == ".jpg") { var path = Path.Combine(Server.MapPath("~/Content/Image"), fileName); t_organisasi.t_path.SaveAs(path); create.t_path = "~/Content/Image/" + fileName; } else { ModelState.AddModelError("", "Foto harus berformat (.jpg)"); return(View(t_organisasi)); } } else { ModelState.AddModelError("", "Ukuran foto tidak boleh lebih dari 2 MB"); return(View(t_organisasi)); } } else { ModelState.AddModelError("", "Foto harus diisi"); return(View(t_organisasi)); } db.t_organisasi.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_organisasi)); }
public ActionResult Edit(int id, t_album t_album) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { t_album album = db.t_album.Find(id); album.album_title = t_album.album_title; album.album_date = DateTime.Now; album.album_desc = t_album.album_desc; album.user_id = db.users.FirstOrDefault(u => u.username == User.Identity.Name).id_user; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_album)); }
public ActionResult Create(t_satuan t_satuan) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_satuan.Create(); create.satuan = t_satuan.satuan; create.tanggal = DateTime.Now; db.t_satuan.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_satuan)); }
public ActionResult Create(t_news_category t_news_category) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_news_category.Create(); create.category_date = DateTime.Now; create.category_title = t_news_category.category_title; create.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); db.t_news_category.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_news_category)); }