Пример #1
0
        public ActionResult HireAction(int?id)
        {
            ViewBag.drpAssert     = CommonController.drpAssert();
            ViewBag.drpEnrollment = CommonController.drpEnrollment();

            if (id != 0)
            {
                InstrumentHire dataset = entities.InstrumentHires.Find(id);
                return(PartialView(dataset));
            }

            else
            {
                return(PartialView());
            }
        }
Пример #2
0
        public ActionResult HireAction(InstrumentHire instrumenthire)
        {
            ModelState.Remove("InstrumentHireId");

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

                if (instrumenthire.InstrumentHireId > 0)
                {
                    var dataset = entities.InstrumentHires.Where(f => f.InstrumentHireId == instrumenthire.InstrumentHireId).FirstOrDefault();
                    if (dataset != null)
                    {
                        dataset.Description        = instrumenthire.Description;
                        dataset.InstrumentAssertID = instrumenthire.InstrumentAssertID;
                        dataset.EnrolmentID        = instrumenthire.EnrolmentID;
                        dataset.InstrumentAssert.InstrumentConditionID = 3;
                        msg = "Hire details Updated Successfully";
                    }
                }
                else
                {
                    entities.InstrumentHires.Add(instrumenthire);
                    InstrumentAssert datasetassert = entities.InstrumentAsserts.Where(f => f.InstrumentAssertID == instrumenthire.InstrumentAssertID).FirstOrDefault();
                    datasetassert.InstrumentConditionID = 3;
                    msg = "New Hire details Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Hire",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            ViewBag.drpAssert     = CommonController.drpAssert();
            ViewBag.drpEnrollment = CommonController.drpEnrollment();

            return(PartialView(instrumenthire));
        }