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

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