// GET: EditMark_Teachers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mark_Teachers mark_Teachers = db.Mark_Teachers.Find(id); if (mark_Teachers == null) { return(HttpNotFound()); } List <Category_Teachers> cts = db.Category_Teachers.Where(c => c.Id_block == mark_Teachers.Сriteria_Teachers.Category_Teachers.Id_block).ToList(); List <Сriteria_Teachers> сrts = db.Сriteria_Teachers.Where(c => c.Id_Category == mark_Teachers.Сriteria_Teachers.Id_Category).ToList(); MarkTeacherViewModel mtvm = new MarkTeacherViewModel() { Categories = new SelectList(cts, "Id", "Name"), SelectedCategoryId = mark_Teachers.Сriteria_Teachers.Id_Category.ToString(), Criterias = new SelectList(сrts, "Id", "Name"), SelectedCriteriaId = mark_Teachers.Id_Criteria.ToString(), Kolvo_ed = (int)mark_Teachers.Kolvo_ed }; return(View(mtvm)); }
// POST: EditMark_Teachers/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Edit(CriteriaListViewModel clvm) //{ // if (ModelState.IsValid) // { // db.Entry(clvm).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); // } // return View(clvm); //} // GET: EditMark_Teachers/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mark_Teachers mark_Teachers = db.Mark_Teachers.Find(id); ViewBag.IdBlock = mark_Teachers.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id; if (mark_Teachers == null) { return(HttpNotFound()); } List <Category_Teachers> cts = db.Category_Teachers.Where(c => c.Id_block == mark_Teachers.Сriteria_Teachers.Category_Teachers.Id_block).ToList(); List <Сriteria_Teachers> сrts = db.Сriteria_Teachers.Where(c => c.Id_Category == mark_Teachers.Сriteria_Teachers.Id_Category).ToList(); MarkTeacherViewModel mtvm = new MarkTeacherViewModel(); ViewBag.BlockStr = mark_Teachers.Сriteria_Teachers.Category_Teachers.Block_Teachers.Name; ViewBag.CategoryStr = mark_Teachers.Сriteria_Teachers.Category_Teachers.Name; ViewBag.CriteriaStr = mark_Teachers.Сriteria_Teachers.Name; ViewBag.Count = mark_Teachers.Kolvo_ed; return(View(mtvm)); }
public IActionResult AddMarkTeacher(MarkTeacherViewModel markTeacher) { if (!ModelState.IsValid) { return(NoContent()); } markTeacher.UserId = Convert.ToInt32(_signInManager.UserManager.GetUserId(User)); _markService.AddMarkTeacher(_mapper.Map <MarkTeacherViewModel, MarkTeacherDto>(markTeacher)); return(Content(JsonConvert.SerializeObject($"Success add mark {markTeacher.Mark}"), "application/json")); }