예제 #1
0
        public ActionResult ManageStudent(int id)
        {
            tblStudent student = new tblStudent();
            student.tblContactDetail = new tblContactDetail();
            if (id != 0)
            {
                student = new StudentBL().GetById(id);
            }

            return PartialView("_ManageStudent", student);
        }
예제 #2
0
        public ActionResult Save(tblStudent oStudent)
        {
            try
            {
                bool Add_Flg = new CommonBL().isNewEntry(oStudent.StudentId);
                if (Add_Flg)
                    new StudentBL().Create(oStudent);
                else
                    new StudentBL().Update(oStudent);

                TempData["successmsg"] = CommonMsg.Success_Update(EntityNames.Student);
                return RedirectToAction("ManageStudent", new { id = oStudent.StudentId });
            }
            catch (Exception ex)
            {
                TempData["errormsg"] = CommonMsg.Error();
                return RedirectToAction("Index");
            }
        }
예제 #3
0
파일: StudentBL.cs 프로젝트: niminc/MVCDemo
        public void Create(tblStudent oStudent)
        {
            try
            {
                using (var ctx = new CRUDSampleEntities())
                {
                    oStudent.ModifiedDate = DateTime.Now;

                    oStudent.CreateDate = DateTime.Now;
                    oStudent.ModifiedDate = DateTime.Now;
                    ctx.tblStudents.Add(oStudent);

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
파일: StudentBL.cs 프로젝트: niminc/MVCDemo
        public void Update(tblStudent oStudent)
        {
            try
            {
                using (var ctx = new CRUDSampleEntities())
                {
                    ctx.tblContactDetails.Attach(oStudent.tblContactDetail);
                    ctx.Entry(oStudent.tblContactDetail).State = EntityState.Modified;

                    ctx.tblStudents.Attach(oStudent);
                    ctx.Entry(oStudent).State = EntityState.Modified;

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }