Exemplo n.º 1
0
        async Task IDataInjector.UpdateDiagnostico(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase Data)
        {
            using (var scope = Ekilibrate.Data.Access.Common.ContainerConfig.ProxyContainer.BeginLifetimeScope("a"))
            {
                try
                {
                    var objController = new Ekilibrate.BL.Controller.Participante.clsDiagnostico(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 del diagnóstico.");
                }
            }
        }
Exemplo n.º 2
0
        //DIAGNOSTICO
        async Task <Int32> IDataInjector.CreateDiagnostico(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase Data)
        {
            using (var scope = Ekilibrate.Data.Access.Common.ContainerConfig.ProxyContainer.BeginLifetimeScope("a"))
            {
                try
                {
                    var objController = new Ekilibrate.BL.Controller.Participante.clsDiagnostico(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 del diagnostico.");
                }
            }
        }
        //[HttpPost]
        //[MultipleButton(Name = "action", Argument = "Guardar")]
        //public async Task<ActionResult> Guardar(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase model)
        //{
        //    return await GrabarInformacionGeneral(model, false);
        //}

        //[HttpPost]
        //[MultipleButton(Name = "action", Argument = "Siguiente")]
        //public async Task<ActionResult> Siguiente(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase model)
        //{
        //    return await GrabarInformacionGeneral(model, true);
        //}

        private async Task <ActionResult> GrabarInformacionGeneral(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase model, string accion)
        {
            try
            {
                BarcoSoftUtilidades.Seguridad.Usuario user = this.HttpContext.GetActualUser();
                int?participante = model.ID_PARTICIPANTE;

                if (model.SEXO == "MASCULINO")
                {
                    model.FEC_NAC_BEBE         = null;
                    model.FEC_ULT_MENSTRUACION = null;
                    model.MUJER_EMBARAZADA     = false;
                }
                else
                {
                    if (model.FEC_ULT_MENSTRUACION != null)
                    {
                        model.MUJER_EMBARAZADA = true;
                    }
                    else
                    {
                        model.MUJER_EMBARAZADA = false;
                    }

                    if (model.FEC_NAC_BEBE != null)
                    {
                        model.MUJER_LACTANCIA = true;
                    }
                    else
                    {
                        model.MUJER_LACTANCIA = false;
                    }
                }

                if (model != null && ModelState.IsValid)
                {
                    using (var scope = EkilibrateUI.Autofac.ContainerConfig.ProxyContainer.BeginLifetimeScope())
                    {
                        var middleTier = scope.Resolve <Ekilibrate.Model.Services.Participante.IDataInjector>();
                        if (participante == null)
                        {
                            await middleTier.CreateDiagnostico(model);
                        }
                        else
                        {
                            await middleTier.UpdateDiagnostico(model);
                        }

                        if (accion == "Siguiente")
                        {
                            return(Redirect("../Participante/Alimentacion"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }
            return(View(model));
        }
 public async Task <ActionResult> Index(Ekilibrate.Model.Entity.Participante.clsDiagnosticoBase model, string accion)
 {
     return(await GrabarInformacionGeneral(model, accion));
 }