public async Task <IActionResult> Edit(int id, [Bind("Id,IdRol,IdOperaciones")] RolOperacion rolOperacion)
        {
            if (id != rolOperacion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rolOperacion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RolOperacionExists(rolOperacion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOperaciones"] = new SelectList(_context.Operaciones, "Id", "Id", rolOperacion.IdOperaciones);
            ViewData["IdRol"]         = new SelectList(_context.Rol, "Id", "Id", rolOperacion.IdRol);
            return(View(rolOperacion));
        }
Beispiel #2
0
        public static void CrearRolOperaciones(int rolId, int operacionId)
        {
            var rolOperacionExist = db.RolOperaciones.Where(r => r.RolId == rolId && r.OperacionId == operacionId).FirstOrDefault();

            if (rolOperacionExist != null)
            {
                if (rolOperacionExist.RolId != rolId && rolOperacionExist.OperacionId != operacionId)
                {
                    RolOperacion rolOperacion = new RolOperacion
                    {
                        RolId       = rolId,
                        OperacionId = operacionId
                    };
                    db.RolOperaciones.Add(rolOperacion);
                    db.SaveChanges();
                }
            }
            else
            {
                RolOperacion rolOperacion = new RolOperacion
                {
                    RolId       = rolId,
                    OperacionId = operacionId
                };
                db.RolOperaciones.Add(rolOperacion);
                db.SaveChanges();
            }
        }
        public OperacionDTO Build(Operacion operacion, RolOperacion rol)
        {
            var operacionDto = OperacionMapper.ConvertirAOperacionDTO(operacion);

            operacionDto.ProximosEstados = operacionWorkflowMapper.ToWorkflowDtoList(
                workflowService.ProximosEstadosPorCodigoYRol(operacion.IdEstadoOperacionNavigation.Codigo, rol)
                );

            return(operacionDto);
        }
        public async Task <IActionResult> Create([Bind("Id,IdRol,IdOperaciones")] RolOperacion rolOperacion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rolOperacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOperaciones"] = new SelectList(_context.Operaciones, "Id", "Id", rolOperacion.IdOperaciones);
            ViewData["IdRol"]         = new SelectList(_context.Rol, "Id", "Id", rolOperacion.IdRol);
            return(View(rolOperacion));
        }
Beispiel #5
0
 public void AgregarOperacion(OperacionesPorEstadoDTO dto, Operacion operacion, RolOperacion rol)
 {
     dto.EnCurso.Add(operacionDtoBuilder.Build(operacion, rol));
 }
Beispiel #6
0
        private OperacionesPorEstadoDTO SetOperacionesPorEstado(List <Operacion> operaciones, RolOperacion rol)
        {
            var porEstadoDto = new OperacionesPorEstadoDTO
            {
                Pendientes  = new List <OperacionDTO>(),
                EnCurso     = new List <OperacionDTO>(),
                Finalizadas = new List <OperacionDTO>()
            };

            operaciones.ForEach(o =>
                                estrategiaAddOperacion
                                .GetValueOrDefault(o.IdEstadoOperacionNavigation.Codigo)
                                .AgregarOperacion(porEstadoDto, o, rol)
                                );

            return(porEstadoDto);
        }
 public List <OperacionWorkflow> ProximosEstadosPorCodigoYRol(string codigoEstadoActual, RolOperacion rol)
 {
     return(higoContext.OperacionWorkflow
            .Include(ow => ow.IdEstadoActualNavigation)
            .Include(ow => ow.IdProximoEstadoNavigation)
            .Where(ow => ow.IdEstadoActualNavigation.Codigo.Equals(codigoEstadoActual))
            .Where(ow => ow.Rol.Equals(rol.ToString()))
            .ToList());
 }