Exemple #1
0
        public ActionResult AssertAction(InstrumentAssert instrumentassert)
        {
            ModelState.Remove("InstrumentAssertID");
            ModelState.Remove("InstrumentCode");

            if (ModelState.IsValid)
            {
                string msg = "";

                if (instrumentassert.InstrumentAssertID > 0)
                {
                    var dataset = entities.InstrumentAsserts.Where(f => f.InstrumentAssertID == instrumentassert.InstrumentAssertID).FirstOrDefault();
                    if (dataset != null)
                    {
                        Instrument instument = entities.Instruments.Where(x => x.InstrumentID == instrumentassert.InstrumentID).FirstOrDefault();
                        String     code      = "SMMS_" + instument.Name + "_00" + instrumentassert.InstrumentAssertID;
                        dataset.InstrumentCode        = code;
                        dataset.InstrumentID          = instrumentassert.InstrumentID;
                        dataset.InstrumentConditionID = instrumentassert.InstrumentConditionID;
                        msg = "Instrument Updated Successfully";
                    }
                }
                else
                {
                    Instrument instument = entities.Instruments.Where(x => x.InstrumentID == instrumentassert.InstrumentID).FirstOrDefault();
                    try
                    {
                        var    insAssert = entities.InstrumentAsserts.Max(x => x.InstrumentAssertID) + 1;
                        String code      = "SMMS_" + instument.Name + "_00" + insAssert;
                        instrumentassert.InstrumentCode = code;
                    }
                    catch
                    {
                        String code = "SMMS_" + instument.Name + "_00" + 1;
                        instrumentassert.InstrumentCode = code;
                    }

                    entities.InstrumentAsserts.Add(instrumentassert);
                    msg = "Instrument Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Assert",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            ViewBag.drpInstrument          = CommonController.drpInstrument();
            ViewBag.drpInstrumentCondition = CommonController.drpInstrumentCondition();

            return(PartialView(instrumentassert));
        }
Exemple #2
0
        public ActionResult MusicAction(Music music)
        {
            ModelState.Remove("MusicID");

            if (ModelState.IsValid)
            {
                string msg = "";

                if (music.MusicID > 0)
                {
                    var dataset = entities.Musics.Where(f => f.MusicID == music.MusicID).FirstOrDefault();
                    if (dataset != null)
                    {
                        dataset.Name        = music.Name;
                        dataset.Description = music.Description;
                        msg = "Music Updated Successfully";
                    }
                }
                else
                {
                    entities.Musics.Add(music);
                    msg = "New Music Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Music",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(PartialView(music));
        }
        public ActionResult CourseAction(CourseLevel courselevel)
        {
            ModelState.Remove("CourseLevelID");

            if (ModelState.IsValid)
            {
                string msg = "";

                if (courselevel.CourseLevelID > 0)
                {
                    var dataset = entities.CourseLevels.Where(f => f.CourseLevelID == courselevel.CourseLevelID).FirstOrDefault();
                    if (dataset != null)
                    {
                        dataset.LevelName = courselevel.LevelName;
                        msg = "Course Level Updated Successfully";
                    }
                }
                else
                {
                    entities.CourseLevels.Add(courselevel);
                    msg = "New Course Level Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "CourseLevel",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(PartialView(courselevel));
        }
Exemple #4
0
        public ActionResult TutorAction(UserTutor usertutor)
        {
            ModelState.Remove("UserID");
            ModelState.Remove("TutorID");

            if (ModelState.IsValid)
            {
                string msg = "";

                if (usertutor.TutorID > 0)
                {
                    var datasetTutor = entities.Tutors.Where(f => f.TutorID == usertutor.TutorID).FirstOrDefault();
                    var datasetUser  = entities.Users.Where(f => f.UserID == datasetTutor.UserID).FirstOrDefault();
                    if (datasetTutor != null && datasetUser != null)
                    {
                        datasetTutor.TutorLevelID = usertutor.TutorLevelID;

                        datasetUser.FirstName  = usertutor.FirstName;
                        datasetUser.LastName   = usertutor.LastName;
                        datasetUser.DOB        = usertutor.DOB;
                        datasetUser.Email      = usertutor.Email;
                        datasetUser.Phone      = usertutor.Phone;
                        datasetUser.Address    = usertutor.Address;
                        datasetUser.Password   = usertutor.Password;
                        datasetUser.UserRoleID = 3;

                        entities.SaveChanges();
                        msg = "Turor details Updated Successfully";
                    }
                }
                else
                {
                    User datasetUser = new User();
                    datasetUser.FirstName  = usertutor.FirstName;
                    datasetUser.LastName   = usertutor.LastName;
                    datasetUser.DOB        = usertutor.DOB;
                    datasetUser.Email      = usertutor.Email;
                    datasetUser.Phone      = usertutor.Phone;
                    datasetUser.Address    = usertutor.Address;
                    datasetUser.Password   = usertutor.Password;
                    datasetUser.UserRoleID = 3;
                    entities.Users.Add(datasetUser);

                    Tutor datasetTutor = new Tutor();
                    int   id           = usertutor.UserID;
                    datasetTutor.UserID       = id;
                    datasetTutor.TutorLevelID = usertutor.TutorLevelID;
                    entities.Tutors.Add(datasetTutor);
                    entities.SaveChanges();
                    msg = "New Tutor Added successfully";
                }

                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Tutors",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            ViewBag.drpTutorLevel = CommonController.drpTutorLevel();
            return(PartialView(usertutor));
        }