Exemple #1
0
        private async Task InsertaIntegranteIIEGC(GrupoColegiadoPartInt model)
        {
            try
            {
                for (int i = 0; i < model.IntegrantesIE.Length; i++)
                {
                    IntegranteGrupoColegiadoInterno obj = new IntegranteGrupoColegiadoInterno();

                    var item  = model.IntegrantesIE[i];
                    var item2 = model.CargosI[i];
                    var item3 = model.NombresIE[i];

                    obj.GrupoColegiadoPartIntId = model.GrupoColegiadoPartIntId;
                    obj.ClaveEmpleado           = item;
                    obj.CargoGC       = item2;
                    obj.FechaRegistro = model.FechaRegistro;
                    obj.Autor         = model.Autor;
                    obj.Nombre        = item3;
                    obj.Estado        = true;

                    var entities = _db.IntegranteGrupoColegiadoInterno.Add(obj);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Exemple #2
0
        public async Task <IntegranteGrupoColegiadoInterno> Create(IntegranteGrupoColegiadoInterno model)
        {
            try
            {
                var result = _db.IntegranteGrupoColegiadoInterno.Add(model);
                await _db.SaveChangesAsync();

                return(result);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task <IHttpActionResult> UpdateEstado([FromBody] IntegranteGrupoColegiadoInterno model)
        {
            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _entityRepo.UpdateEstado(model);

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

                return(InternalServerError(e));
            }
        }
Exemple #4
0
        public async Task Update(IntegranteGrupoColegiadoInterno model)
        {
            try
            {
                var _model = await _db.IntegranteGrupoColegiadoInterno.FirstOrDefaultAsync(e => e.IntegranteGrupoColegiadoInternoId == model.IntegranteGrupoColegiadoInternoId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Exemple #5
0
        public async Task UpdateEstado(IntegranteGrupoColegiadoInterno model)
        {
            try
            {
                var _model = await _db.IntegranteGrupoColegiadoInterno.FirstOrDefaultAsync(e => e.IntegranteGrupoColegiadoInternoId == model.IntegranteGrupoColegiadoInternoId);

                if (_model != null)
                {
                    _model.Estado = model.Estado;

                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task <IHttpActionResult> Update([FromBody] IntegranteGrupoColegiadoInterno model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _entityRepo.Update(model);

                return(Ok("Registro actualizado exitosamente!"));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                return(InternalServerError(e));
            }
        }
        public async Task <IHttpActionResult> Create([FromBody] IntegranteGrupoColegiadoInterno model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                var result = await _entityRepo.Create(model);

                return(Ok(result));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                if (e.Message.Substring(0, 44) == "An error occurred while updating the entries")
                {
                    return(BadRequest("Ya existe un registro con ese nombre"));
                }
                return(InternalServerError(e));
            }
        }