public ActionResult GiveMission(bgk_gorev mission) { if (ModelState.IsValid) { mission.OlusturanID = (int)Session["memberID"]; mission.OlusturulmaTarihi = DateTime.Now; mission.Tip = 1; Db.bgk_gorev.Add(mission); var group = Db.bgk_grup.Find(mission.GrupID); foreach (var member in group.bgk_grup_uye.ToList()) { string cevap = Request.Form["member_" + member.UyeID.ToString()]; if (Request.Form["member_" + member.UyeID.ToString()] != null && Request.Form["member_" + member.UyeID.ToString()] != "false") { bgk_gorev_uye bgk_gorev_uye = new bgk_gorev_uye(); bgk_gorev_uye.GorevID = mission.Id; bgk_gorev_uye.UyeID = member.UyeID; bgk_gorev_uye.Tamamlandi = false; bgk_gorev_uye.BaslangicTarihi = DateTime.Now; bgk_gorev_uye.BitisTarihi = (DateTime)mission.BitisTarihi; bgk_gorev_uye.Onay = null; Db.bgk_gorev_uye.Add(bgk_gorev_uye); Db.SaveChanges(); } } Db.SaveChanges(); return(RedirectToAction("details", new { id = group.Id })); } return(View(mission)); }
public ActionResult EditMission(bgk_gorev mission) { if (ModelState.IsValid) { Db.Entry(mission).State = EntityState.Modified; Db.SaveChanges(); return(RedirectToAction("details", new { id = mission.Id })); } return(View(mission)); }
public static void DeleteMission(bgk_gorev mission) { BGKEntities Db = new BGKEntities(); foreach (var member in mission.bgk_gorev_uye) { Db.bgk_gorev_uye.Remove(member); } Db.bgk_gorev.Remove(mission); Db.SaveChanges(); }
public ActionResult DeleteMission(bgk_gorev model) { bgk_gorev mission = Db.bgk_gorev.Find(model.Id); foreach (var member in mission.bgk_gorev_uye) { member.bgk_uye.Puan -= member.Kabul == true ? mission.Puan : 0; Db.bgk_gorev_uye.Remove(member); } Db.bgk_gorev.Remove(mission); Db.SaveChanges(); return(Content("<script>$.BGK.SuccessModal('Görevi başarılı bir şekilde kaldırdınız.', function (){ window.location.href='" + Url.Action("CreatedMissions") + "'; }, 2000);</script>")); }
public ActionResult GiveMission(bgk_gorev mission) { if (ModelState.IsValid) { mission.OlusturanID = (int)Session["memberID"]; mission.Tip = 2; mission.Onay = true; mission.OlusturulmaTarihi = DateTime.Now; Db.bgk_gorev.Add(mission); Db.SaveChanges(); return(RedirectToAction("CreatedMissions")); } return(View(mission)); }
public ActionResult TakeMission(bgk_gorev mission) { var new_mission = new bgk_gorev_uye(); mission = Db.bgk_gorev.Find(mission.Id); new_mission.GorevID = mission.Id; new_mission.UyeID = (int)Session["memberID"]; new_mission.BaslangicTarihi = Convert.ToDateTime(Request.Form["BaslangicTarihi"]); new_mission.BitisTarihi = Convert.ToDateTime(Request.Form["BitisTarihi"]); new_mission.Onay = true; new_mission.Tamamlandi = false; Db.bgk_gorev_uye.Add(new_mission); Db.SaveChanges(); return(Content("<script>$.BGK.SuccessModal('Görevi başarıyla aldınız.', function (){ window.location.href='" + Url.Action("Details", new { id = mission.Id }) + "'; }, 1500);</script>")); }
public ActionResult GiveMission(int id) { var group = Db.bgk_grup.Find(id); if (group == null) { return(HttpNotFound()); } ViewBag.group = group; bgk_gorev mission = new bgk_gorev { GrupID = id }; return(View(mission)); }
public ActionResult GiveMission(int id) { var category = Db.bgk_gorev_kategori.Find(id); if (category == null || category.OlusturanID != (int)Session["memberID"]) { return(HttpNotFound()); } ViewBag.category = category; var first = category.bgk_gorev.OrderByDescending(x => x.Sira).FirstOrDefault(); bgk_gorev mission = new bgk_gorev { KategoriID = id, Sira = first == null ? 0 : first.Sira }; return(View(mission)); }