Esempio n. 1
0
        public ActionResult Edit(ExamInfoDetail model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ExamInfoDetail obj = db.ExamInfoDetails.Find(model.Id);
                    obj.TotalMarks = model.TotalMarks;
                    obj.PassMarks  = model.PassMarks;


                    db.Entry(obj).State = EntityState.Modified;
                    db.SaveChanges();

                    TempData["ok"]      = "ok";
                    TempData["message"] = "<span class=\"color-green\">" + model.ExamName + " " + model.SubjectName + " Successfully Updated!</span>";
                    return(RedirectToAction("Index"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                TempData["message"] = "<span class=\"color-red\">" + ex.Message + "</span>";
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 2
0
        public ActionResult Save(View_ExamDetail model, int?SubjectId)
        {
            if (model.TypeDetails.Count > 0)
            {
                foreach (var item in model.TypeDetails)
                {
                    if (item.chk == true)
                    {
                        ExamInfoDetail obj = new ExamInfoDetail();
                        obj.EntryBy    = User.Identity.Name;
                        obj.EntryDate  = DateTime.Now;
                        obj.ExamId     = model.Examinfo.Id;
                        obj.ExamTypeId = db.ExamTypeInfos.Where(t => t.ExamTypeName == item.TypeName).SingleOrDefault().ExamTypeId;
                        obj.SubjectId  = SubjectId.Value;
                        obj.TotalMarks = Convert.ToDecimal(item.TotalMark.Value);
                        obj.PassMarks  = Convert.ToDecimal(item.PassMark.Value);

                        //check is already exists update it
                        var isData = new ExamInfoDetail();
                        isData = db.ExamInfoDetails.Where(t => t.ExamId == obj.ExamId && t.SubjectId == obj.SubjectId && t.ExamTypeId == obj.ExamTypeId).SingleOrDefault();

                        if (isData != null)
                        {
                            isData.TotalMarks = Convert.ToDecimal(item.TotalMark.Value);
                            isData.PassMarks  = Convert.ToDecimal(item.PassMark.Value);

                            db.Entry(isData).State = EntityState.Modified;
                        }
                        else
                        {
                            db.ExamInfoDetails.Add(obj);
                        }
                    }
                }

                db.SaveChanges();

                TempData["ok"]      = "ok";
                TempData["message"] = "<span class=\"color-green\">Successfully Saved!</span>";
                return(RedirectToAction("Index"));
            }



            return(null);
        }
Esempio n. 3
0
        public ActionResult Edit(int id)
        {
            try
            {
                ExamInfoDetail obj = db.ExamInfoDetails.Find(id);

                obj.ExamName    = db.ExamInfoes.Find(obj.ExamId).ExamName;
                obj.SubjectName = db.SubjectInfoes.Find(obj.SubjectId).SubjectName;
                obj.ExamType    = db.ExamTypeInfos.Find(obj.ExamTypeId).ExamTypeName;

                return(View(obj));
            }
            catch (Exception ex)
            {
                TempData["message"] = "<span class=\"color-red\">" + ex.Message + "</span>";
                return(RedirectToAction("Index"));
            }
        }