public async Task <IHttpActionResult> Update(BecarioDirigido Obj)
        {
            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                if (Obj.Adjunto != null)
                {
                    //Elimar archivo
                    if (Obj.Adjunto.nombre == "eliminar")
                    {
                        int id = Convert.ToInt32(Obj.AdjuntoId);
                        Obj.AdjuntoId = null;
                        await _repository.Update(Obj);

                        await _adjuntoRepo.Delete(id);

                        return(Ok());
                    }
                    ///Agregar archivo al editar
                    if (Obj.Adjunto.AdjuntoId == 0)
                    {
                        Adjunto key = await _adjuntoRepo.CreateAd(Obj.Adjunto);

                        Obj.AdjuntoId         = key.AdjuntoId;
                        Obj.Adjunto.AdjuntoId = key.AdjuntoId;
                        await _repository.Update(Obj);

                        return(Ok(key));
                    }
                }
                //solución de ALAN replicada
                if (Obj.Adjunto != null)
                {
                    Obj.AdjuntoId = Obj.Adjunto.AdjuntoId;
                }
                await _repository.Update(Obj);

                ////Agregar a OC
                if (Obj.EstadoFlujoId == 3)
                {
                    await new NuevoOCRepository().Create(
                        new NuevoOC("CH",
                                    "BecarioDirigido",
                                    Obj.NombreEstancia,
                                    "IndexCH.html#/detallesbecariodirigido/" + Obj.BecarioDirigidoId + "/",
                                    Obj.BecarioDirigidoId + ""
                                    ));
                }
                return(Ok(Obj));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                return(InternalServerError(e));
            }
        }
        public async Task <IHttpActionResult> ValidarDuplicados(BecarioDirigido Obj)
        {
            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                var exis = await _repository.ValidarDuplicados(Obj);

                return(Ok(exis));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                return(InternalServerError(e));
            }
        }
        public async Task <IHttpActionResult> UpdateEstado(BecarioDirigido Obj)
        {
            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _repository.UpdateEstado(Obj);

                return(Ok("Registro actualizado correctamente!"));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                return(InternalServerError(e));
            }
        }
예제 #4
0
                                                         internal async Task UpdateByBecario(BecarioDirigido Obj, int estado)
                                                         {
                                                             try
                                                             {
                                                                 var td = await _ctx.TesisDirigida.FirstOrDefaultAsync(e => e.TesisDirigidaId == Obj.TesisDirigidaId);

                                                                 if (td != null)
                                                                 {
                                                                     td.EstadoFlujoId     = estado;
                                                                     td.AdjuntoId         = Obj.AdjuntoId;
                                                                     td.Autor             = Obj.NombreBecario;
                                                                     td.BecarioDirigidoId = Obj.BecarioDirigidoId;
                                                                     td.ClavePersona      = Obj.ClavePersona;
                                                                     td.EstadoFlujoId     = 3;
                                                                     td.FechaInicio       = Obj.FechaInicio;
                                                                     td.FechaTermino      = Obj.FechaTermino;
                                                                     td.GradoAcademicoId  = Obj.TipoBecaId;
                                                                     td.Titulo            = Obj.NombreEstancia;
                                                                     td.FechaValidacion   = Obj.FechaValidacion;
                                                                     await _ctx.SaveChangesAsync();
                                                                 }
                                                             }
                                                             catch (Exception e)
                                                             {
                                                                 throw new Exception(e.Message, e);
                                                             }
                                                         }