예제 #1
0
        public PartialViewResult GetEquipmentMonitoringView(string id)
        {
            Equipment equipment = new BusinessLayer <Equipment>(new CapaNavDocDal()).Get(id.ToInt32());
            EquipmentMonitoringViewModel model = equipment.ToEquipmentMonitoringViewModel();

            return(PartialView("EquipmentMonitoringView", model));
        }
예제 #2
0
        public ActionResult UpdateEquipmentMonitoring(EquipmentMonitoringViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Users = new BusinessLayer <User>(new CapaNavDocDal()).GetList().Select(u => u.ToUserCallViewModel().UserCall).ToList();
                return(PartialView("EquipmentMonitoringView", model));
            }

            BusinessLayer <Equipment> ebl       = new BusinessLayer <Equipment>(new CapaNavDocDal());
            BusinessLayer <User>      ubl       = new BusinessLayer <User>(new CapaNavDocDal());
            Equipment         equipment         = ebl.Get(model.EquipmentId.ToInt32());
            UserCallViewModel userCallViewModel = ubl.GetList().Select(u => u.ToUserCallViewModel()).FirstOrDefault(u => u.UserCall == model.SelectedUserCall);

            if (userCallViewModel == null)
            {
                return(Json(new { success = true }));
            }

            equipment.MonitoringUserId = userCallViewModel.UserId.ToInt32();
            equipment.MonitoringDate   = DateTime.ParseExact(model.Date, "dd-mm-yyyy", CultureInfo.InvariantCulture);
            ebl.Update(equipment);
            return(Json(new { success = true }));
        }