Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,StudentID,FeeChallanID,PaymentAmount,PaymentDate")] AspNetStudent_Payment aspNetStudent_Payment)
        {
            var TransactionObj = db.Database.BeginTransaction();

            try
            {
                if (ModelState.IsValid)
                {
                    db.AspNetStudent_Payment.Add(aspNetStudent_Payment);
                    db.SaveChanges();
                }
                TransactionObj.Commit();
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


                var        UserNameLog = User.Identity.Name;
                AspNetUser a           = db.AspNetUsers.First(x => x.UserName == UserNameLog);
                string     UserIDLog   = a.Id;
                var        classObjLog = Request.Form["ClassID"];
                var        logMessage  = "Student Payment Added : " + aspNetStudent_Payment.StudentID + ", FeeChallan ID: " + aspNetStudent_Payment.FeeChallanID + ", Payment Amount: " + aspNetStudent_Payment.PaymentAmount + ", Payment Date: " + aspNetStudent_Payment.PaymentDate;

                var LogControllerObj = new AspNetLogsController();
                LogControllerObj.CreateLogSave(logMessage, UserIDLog);
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                return(RedirectToAction("Index"));
            }


            catch (Exception)
            {
                TransactionObj.Dispose();
            }

            ViewBag.FeeChallanID = new SelectList(db.AspNetFeeChallans, "Id", "Id", aspNetStudent_Payment.FeeChallanID);
            ViewBag.StudentID    = new SelectList(db.AspNetUsers, "Id", "Email", aspNetStudent_Payment.StudentID);
            return(View(aspNetStudent_Payment));
        }
Ejemplo n.º 2
0
        // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public JsonResult AddLessonPlan(lessonPlan LessonPlan)
        {
            var TransactionObj = db.Database.BeginTransaction();

            try
            {
                AspNetLessonPlan aspNetLessonPlan = new AspNetLessonPlan();
                aspNetLessonPlan.LessonPlanNo = LessonPlan.lessonPlanNo;
                aspNetLessonPlan.SubjectID    = LessonPlan.subjectID;
                aspNetLessonPlan.Date         = LessonPlan.Date;
                aspNetLessonPlan.Duration     = LessonPlan.Duration;
                db.AspNetLessonPlans.Add(aspNetLessonPlan);
                db.SaveChanges();

                int LessonPlanID = db.AspNetLessonPlans.Max(x => x.Id);

                foreach (var topic in LessonPlan.Topics)
                {
                    AspNetLessonPlan_Topic lessonPlanTopic = new AspNetLessonPlan_Topic();
                    lessonPlanTopic.TopicID      = topic;
                    lessonPlanTopic.LessonPlanID = LessonPlanID;
                    db.AspNetLessonPlan_Topic.Add(lessonPlanTopic);
                    db.SaveChanges();
                }

                if (LessonPlan.BreakDown != null)
                {
                    foreach (var breakdown in LessonPlan.BreakDown)
                    {
                        AspNetLessonPlanBreakdown aspNetLessonBreakdown = new AspNetLessonPlanBreakdown();
                        aspNetLessonBreakdown.LessonPlanID       = LessonPlanID;
                        aspNetLessonBreakdown.Minutes            = breakdown.Minutes;
                        aspNetLessonBreakdown.Resources          = breakdown.Resources;
                        aspNetLessonBreakdown.BreakDownHeadingID = breakdown.HeadingID;
                        aspNetLessonBreakdown.Description        = WebUtility.HtmlEncode(breakdown.Description).ToString();
                        db.AspNetLessonPlanBreakdowns.Add(aspNetLessonBreakdown);
                        db.SaveChanges();
                    }
                }
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                var        UserNameLog = User.Identity.Name;
                AspNetUser a           = db.AspNetUsers.First(x => x.UserName == UserNameLog);
                string     UserIDLog   = a.Id;
                var        logMessage  = "New LessonPlan Added, SubjectID: " + LessonPlan.subjectID + ", Date: " + LessonPlan.Date;

                var LogControllerObj = new AspNetLogsController();
                LogControllerObj.CreateLogSave(logMessage, UserIDLog);

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                db.SaveChanges();
                TransactionObj.Commit();
            }

            catch (Exception)
            {
                TransactionObj.Dispose();
            }

            return(Json("data", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public void EditLessonPlan1234(EditLessonPlanType LessonPlan)
        {
            var TransactionObj = db.Database.BeginTransaction();

            try
            {
                var lessonID = LessonPlan.LessonPlanID;
                AspNetLessonPlan aspNetLessonPlan = db.AspNetLessonPlans.FirstOrDefault(x => x.Id == lessonID);
                //aspNetLessonPlan.LessonPlanNo = LessonPlan.lessonPlanNo;
                aspNetLessonPlan.SubjectID = LessonPlan.subjectID;
                aspNetLessonPlan.Date      = LessonPlan.Date;
                aspNetLessonPlan.Duration  = LessonPlan.Duration;
                //db.AspNetLessonPlans.Add(aspNetLessonPlan);
                db.SaveChanges();

                int LessonPlanID = aspNetLessonPlan.Id;

                var Lesson_TopicList = (from lesson_topic in db.AspNetLessonPlan_Topic
                                        where lesson_topic.LessonPlanID == LessonPlanID
                                        select lesson_topic).ToList();

                int count = 1;
                do
                {
                    var lessonObj = db.AspNetLessonPlan_Topic.FirstOrDefault(x => x.LessonPlanID == LessonPlanID);

                    if (lessonObj == null)
                    {
                        count = 0;
                        continue;
                    }
                    db.AspNetLessonPlan_Topic.Attach(lessonObj);
                    db.AspNetLessonPlan_Topic.Remove(lessonObj);
                    db.SaveChanges();
                }while (count == 1);

                foreach (var topic in LessonPlan.Topics)
                {
                    AspNetLessonPlan_Topic lessonPlanTopic = new AspNetLessonPlan_Topic();
                    lessonPlanTopic.TopicID      = topic;
                    lessonPlanTopic.LessonPlanID = LessonPlanID;
                    db.AspNetLessonPlan_Topic.Add(lessonPlanTopic);
                    db.SaveChanges();
                }

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                var        UserNameLog = User.Identity.Name;
                AspNetUser a           = db.AspNetUsers.First(x => x.UserName == UserNameLog);
                string     UserIDLog   = a.Id;
                var        logMessage  = "LessonPlan Edited, LessonPlanID: " + lessonID + ", Date: " + LessonPlan.Date;

                var LogControllerObj = new AspNetLogsController();
                LogControllerObj.CreateLogSave(logMessage, UserIDLog);

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                db.SaveChanges();
                TransactionObj.Commit();
            }

            catch (Exception)
            {
                TransactionObj.Dispose();
            }
        }