Exemplo n.º 1
0
        public async Task <ActionResult> Index(Ekilibrate.Model.Entity.Participante.clsRiesgoBase model, string accion)
        {
            try
            {
                if (model != null && ModelState.IsValid)
                {
                    using (var scope = EkilibrateUI.Autofac.ContainerConfig.ProxyContainer.BeginLifetimeScope())
                    {
                        BarcoSoftUtilidades.Seguridad.Usuario user = this.HttpContext.GetActualUser();

                        if (user == null)
                        {
                            return(Redirect("~/SitioAdministrativo/Home/Login?ReturnUrl=%2fParticipante%2fRiesgo"));
                        }

                        var middleTierRet = scope.Resolve <Ekilibrate.Model.Services.Participante.IDataRetriever>();
                        var middleTier    = scope.Resolve <Ekilibrate.Model.Services.Participante.IDataInjector>();
                        int?participante  = model.ID_PARTICIPANTE;

                        if (participante == 0)
                        {
                            model.ID_PARTICIPANTE = user.IdPersona;
                            await middleTier.CreateRiesgo(model);
                        }
                        else
                        {
                            await middleTier.UpdateRiesgo(model);
                        }

                        if (accion == "Siguiente")
                        {
                            return(Redirect("../Participante/Cuidado"));
                        }

                        var Result = await middleTierRet.GetRiesgos(user.IdPersona);

                        return(View(Result));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }
            return(View(model));
        }
Exemplo n.º 2
0
        //RIESGO
        async Task <Int32> IDataInjector.CreateRiesgo(Ekilibrate.Model.Entity.Participante.clsRiesgoBase Data)
        {
            using (var scope = Ekilibrate.Data.Access.Common.ContainerConfig.ProxyContainer.BeginLifetimeScope("a"))
            {
                try
                {
                    var objController = new Ekilibrate.BL.Controller.Participante.clsRiesgo(scope);
                    var result        = await objController.Create(Data);

                    var DBContext = scope.Resolve <DBTrnContext>();
                    DBContext.CommitTransaction();
                    return(result);
                }
                catch (FaultException ex)
                {
                    throw ex;
                }
                catch (Exception)
                {
                    throw new FaultException("Error al registrar los datos de riesgo.");
                }
            }
        }
Exemplo n.º 3
0
        async Task IDataInjector.UpdateRiesgo(Ekilibrate.Model.Entity.Participante.clsRiesgoBase Data)
        {
            using (var scope = Ekilibrate.Data.Access.Common.ContainerConfig.ProxyContainer.BeginLifetimeScope("a"))
            {
                try
                {
                    var objController = new Ekilibrate.BL.Controller.Participante.clsRiesgo(scope);
                    await objController.Update(Data);

                    var DBContext = scope.Resolve <DBTrnContext>();
                    DBContext.CommitTransaction();
                }
                catch (FaultException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    var objController = new Ekilibrate.BL.Common.clsLog(scope);
                    objController.GuardarLog(ex);
                    throw new FaultException("Error al actualizar datos de riesgo.");
                }
            }
        }