Beispiel #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));
        }
Beispiel #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());
            }
        }
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     try
     {
         using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
         {
             InstumentService instumentService = entity.InstumentServices.Where(f => f.InstrumentHireId == (Int32)value).FirstOrDefault();
             if (instumentService == null)
             {
                 return(ValidationResult.Success);
             }
             else
             {
                 return(new ValidationResult("Instrument is being serviced."));
             }
         }
     }
     catch
     {
         return(new ValidationResult("Instrument is being serviced."));
     }
 }