public ActionResult Create(StudentAward studentAward) { try { if (Request.Files.Count == 1) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(file.InputStream)) { studentAward.Photo = reader.ReadBytes(file.ContentLength); } } } _ctx.StudentAwards.Add(studentAward); _ctx.SaveChanges(); return RedirectToAction("List", new RouteValueDictionary( new { controller = "StudentAward", action = "List", StudentId = studentAward.Student_ID })); } catch { return View(); } }
// GET: StudentAward/Create public ActionResult Create(long studentId) { var studentAwardModel = new StudentAward() { Student_ID =studentId }; return View(studentAwardModel); }
public void UpdateAward(StudentAward award) { _repository.Update(award); _unitOfWork.Commit(); }
public ActionResult Edit(StudentAward studentAward) { _ctx.StudentAwards.Attach(studentAward); _ctx.Entry(studentAward).State=EntityState.Modified; _ctx.SaveChanges(); return RedirectToAction("List", new RouteValueDictionary( new { controller = "StudentAward", action = "List", StudentId = studentAward.Student_ID })); }
public void CreateAward(StudentAward award) { _repository.Add(award); _unitOfWork.Commit(); }