示例#1
0
        public ActionResult ServiceAction(InstumentService service)
        {
            ModelState.Remove("InstumentServiceID");

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

                if (service.InstumentServiceID > 0)
                {
                    var dataset = entities.InstumentServices.Where(f => f.InstumentServiceID == service.InstumentServiceID).FirstOrDefault();
                    if (dataset != null)
                    {
                        dataset.Problem          = service.Problem;
                        dataset.Date             = service.Date;
                        dataset.Comments         = service.Comments;
                        dataset.InstrumentHireId = service.InstrumentHireId;
                        dataset.TechnicianID     = service.TechnicianID;
                        InstrumentAssert instrumentAssert = entities.InstrumentAsserts.Where(f => f.InstrumentAssertID == service.InstrumentHire.InstrumentAssertID).FirstOrDefault();
                        instrumentAssert.InstrumentConditionID = 2;
                        msg = "Instrument service Updated Successfully";
                    }
                }
                else
                {
                    entities.InstumentServices.Add(service);
                    InstrumentAssert instrumentAssert = entities.InstrumentAsserts.Where(f => f.InstrumentAssertID == service.InstrumentHire.InstrumentAssertID).FirstOrDefault();
                    instrumentAssert.InstrumentConditionID = 2;
                    msg = "Instrument Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Service",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            ViewBag.drpInstrumentHire = CommonController.drpInstrumentHire();
            ViewBag.drpTechnician     = CommonController.drpTechnician();

            return(PartialView(service));
        }
示例#2
0
        public ActionResult ServiceAction(int?id)
        {
            ViewBag.drpInstrumentHire = CommonController.drpInstrumentHire();
            ViewBag.drpTechnician     = CommonController.drpTechnician();


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

            else
            {
                return(PartialView());
            }
        }