public async Task <ActionResult <TopicGroup> > PostTopicGroup(TopicGroup topicGroup) { _context.TopicGroup.Add(topicGroup); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTopicGroup", new { id = topicGroup.Id }, topicGroup)); }
public ActionResult Create([Bind(Include = "ID,Name")] TopicGroup topicGroup) { if (ModelState.IsValid) { var context = new DLSMEntities(); TopicGroup t = context.TopicGroups.Where(p => p.Name == topicGroup.Name).FirstOrDefault(); if (t != null) { // Cannot delete becasue Topic group is using another process TempData["Msg"] = "ชื่อกลุ่มปัญหานี้มีอยู่แล้วในระบบ"; return(RedirectToAction("Create", new { ViewBag.Msg })); } else { db.TopicGroups.Add(topicGroup); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Issues, "ID", "Subject", topicGroup.ID); ViewBag.ID = new SelectList(db.Topics, "ID", "Subject", topicGroup.ID); return(View(topicGroup)); }
public async Task <IActionResult> PutTopicGroup(int id, TopicGroup topicGroup) { if (id != topicGroup.Id) { return(BadRequest()); } _context.Entry(topicGroup).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TopicGroupExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: TopicGroups/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TopicGroup topicGroup = db.TopicGroups.Find(id); if (topicGroup == null) { return(HttpNotFound()); } return(View(topicGroup)); }
public ActionResult DeleteConfirmed(int id) { var context = new DLSMEntities(); Topic topic = context.Topics.Where(p => p.TgID == id).FirstOrDefault(); if (topic != null) { // Cannot delete becasue Topic group is using another process TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลมีการถูกใช้งานอยู่"; return(RedirectToAction("Edit", new { id = id, ViewBag.Msg })); } else { // Can delete topic group TopicGroup topicGroup = db.TopicGroups.Find(id); db.TopicGroups.Remove(topicGroup); db.SaveChanges(); } return(RedirectToAction("Index")); }
// GET: TopicGroups/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TopicGroup topicGroup = db.TopicGroups.Find(id); if (topicGroup == null) { return(HttpNotFound()); } if (null != TempData["Msg"]) { ViewBag.Msg = TempData["Msg"].ToString(); } ViewBag.ID = new SelectList(db.Issues, "ID", "Subject", topicGroup.ID); ViewBag.ID = new SelectList(db.Topics, "ID", "Subject", topicGroup.ID); return(View(topicGroup)); }
public TopicGroup Edit(int topicGroupId, TopicGroup topicGroup) { return(_topicGroupRepository.Edit(topicGroupId, topicGroup)); }
public TopicGroup Create(TopicGroup topicGroup) { return(_topicGroupRepository.Create(topicGroup)); }