Example #1
0
        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();
            }
        }
Example #2
0
        // GET: StudentAward/Create
        public ActionResult Create(long studentId)
        {
            var studentAwardModel = new StudentAward()
            {
               Student_ID  =studentId
            };

            return View(studentAwardModel);
        }
Example #3
0
 public void UpdateAward(StudentAward award)
 {
     _repository.Update(award);
     _unitOfWork.Commit();
 }
Example #4
0
        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 }));
        }
Example #5
0
 public void CreateAward(StudentAward award)
 {
     _repository.Add(award);
     _unitOfWork.Commit();
 }