コード例 #1
0
        public override ActionResult CreateForEquipo(int id)
        {
            //SSOHelper.Authenticate();
            //if (SSOHelper.CurrentIdentity == null)
            //{
            //    string ssoUrl = SSOHelper.Configuration["SSO_URL"] as string;
            //    Response.Redirect(ssoUrl + "/Login.aspx");
            //}

            ViewBag.ChecklistId = new SelectList(db.ChecklistsMantenimientoPreventivo, "ChecklistMantenimientoPreventivoId", "Nombre");

            var equipo = db.Equipos.Find(id);
            var odt    = new OrdenDeTrabajoMantenimientoPreventivo
            {
                EquipoId        = equipo.EquipoId,
                Equipo          = equipo,
                Estado          = OrdenDeTrabajoEstado.Abierta,
                FechaInicio     = DateTime.Now,
                Prioridad       = OrdenDeTrabajoPrioridad.Normal,
                UsuarioInicio   = (SSOHelper.CurrentIdentity != null ? SSOHelper.CurrentIdentity.Fullname : "Usuario Anónimo"),
                UsuarioCreacion = (SSOHelper.CurrentIdentity != null ? SSOHelper.CurrentIdentity.Fullname : "Usuario Anónimo")
            };

            var model = new MPViewModel();

            model.Odt = odt;
            model.NuevaObservacion = NuevaObservacion();
            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult> Reparar(MPViewModel vm, IEnumerable <GastoOrdenDeTrabajo> gastos)
        {
            //SSOHelper.Authenticate();
            //if (SSOHelper.CurrentIdentity == null)
            //{
            //    string ssoUrl = SSOHelper.Configuration["SSO_URL"] as string;
            //    Response.Redirect(ssoUrl + "/Login.aspx");
            //}

            try
            {
                OrdenDeTrabajoMantenimientoPreventivo orden = await db.ODTMantenimientosPreventivos
                                                              .Include(o => o.SolicitudesRespuestos)
                                                              .Where(o => o.OrdenDeTrabajoId == vm.Odt.OrdenDeTrabajoId)
                                                              .SingleOrDefaultAsync();

                if (orden == null)
                {
                    return(HttpNotFound());
                }

                orden.ChecklistCompleto = vm.Odt.ChecklistCompleto;
                orden.Estado            = OrdenDeTrabajoEstado.Cerrada;
                orden.FechaCierre       = DateTime.Now;
                orden.UsuarioCierre     = (SSOHelper.CurrentIdentity != null ? SSOHelper.CurrentIdentity.Fullname : "Usuario Anónimo");

                //gastos
                if (gastos != null && gastos.Count() > 0)
                {
                    SaveGastos(gastos, orden.OrdenDeTrabajoId);
                }

                //solicitudes
                CloseSolicitudesRepuestos(orden);

                //observaciones
                SaveNuevaObservacion(vm.NuevaObservacion, orden);

                //archivo
                if (vm.ChecklistCompletoFile != null && vm.ChecklistCompletoFile.ContentLength > 0)
                {
                    orden.ChecklistCompletoFileExtension = Path.GetExtension(vm.ChecklistCompletoFile.FileName);
                    orden.ChecklistCompletoContentType   = vm.ChecklistCompletoFile.ContentType;

                    using (var reader = new BinaryReader(vm.ChecklistCompletoFile.InputStream))
                    {
                        orden.ChecklistCompletoContent = reader.ReadBytes(vm.ChecklistCompletoFile.ContentLength);
                    }
                }

                db.Entry(orden).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
            catch (DbEntityValidationException e)
            {
                Debug.WriteLine(e.Data);
            }
            return(RedirectToAction("Details", new { id = vm.Odt.OrdenDeTrabajoId }));
        }
コード例 #3
0
        override public ActionResult Reparar(int id)
        {
            var odt   = db.ODTMantenimientosPreventivos.Find(id);
            var model = new MPViewModel();

            model.Odt = odt;
            model.NuevaObservacion = NuevaObservacion();
            return(View(model));
        }
コード例 #4
0
        public ActionResult CreateForEquipo(MPViewModel vm)
        {
            if (vm.Odt.ChecklistId != 0)
            {
                vm.Odt.Checklist     = db.ChecklistsMantenimientoPreventivo.Find(vm.Odt.ChecklistId);
                vm.Odt.FechaInicio   = DateTime.Now;
                vm.Odt.fechaCreacion = DateTime.Now;
                SaveNuevaObservacion(vm.NuevaObservacion, vm.Odt);
                db.ODTMantenimientosPreventivos.Add(vm.Odt);
                db.SaveChanges();

                return(RedirectToAction("Details", new { id = vm.Odt.OrdenDeTrabajoId }));
            }

            ViewBag.ChecklistId = new SelectList(db.ChecklistsMantenimientoPreventivo, "ChecklistMantenimientoPreventivoId", "Nombre", vm.Odt.ChecklistId);
            return(View(vm));
        }