Beispiel #1
0
        public IHttpActionResult Insert([FromBody] AreaCentroCostoInsertModel model)
        {
            try {
                var id_registro = 0;

                EmpresaCentroModel empresaCentroModel = empresaCentroService.GetSingle(ec => ec.CE_ID_EMPRESA == model.CE_ID_EMPRESA && ec.CC_ID_CENTRO_COSTO == model.CC_ID_CENTRO_COSTO);
                if (empresaCentroModel != null)
                {
                    id_registro = empresaCentroModel.EC_ID_REGISTRO;
                }
                else
                {
                    return(BadRequest("No existe relación empresa centro de costo"));
                }
                int activo = Convert.ToInt16(BusinessEnumerations.Estatus.ACTIVO);
                AreaCentroCostoModel areaCentroInsert = new AreaCentroCostoModel();
                areaCentroInsert.EC_ID_REGISTRO      = id_registro;
                areaCentroInsert.AD_ESTATUS          = Convert.ToInt16(BusinessEnumerations.Estatus.ACTIVO);
                areaCentroInsert.CA_ID_AREA          = model.CA_ID_AREA;
                areaCentroInsert.AD_FECHA_CREACION   = DateTime.Now;
                areaCentroInsert.AD_USUARIO_CREACION = User.Identity.GetUserId();
                var objExits = service.GetSingle(x => x.EC_ID_REGISTRO == areaCentroInsert.EC_ID_REGISTRO && x.AD_ESTATUS == activo && x.CA_ID_AREA == areaCentroInsert.CA_ID_AREA);
                if (objExits != null)
                {
                    BadRequest("El area centro ya existe");
                }
                service.Insert(areaCentroInsert);
                return(Ok());
            }

            catch (Exception e) {
                return(BadRequest("No se pueden guardar los cambios"));
            }
        }
 public IHttpActionResult Put([FromBody] EmpresaCentroModel model)
 {
     service.Update(model);
     return(Ok());
 }
 public IHttpActionResult Post([FromBody] EmpresaCentroModel model)
 {
     model.EC_ESTATUS = 1;
     return(Ok(service.Insert(model, true)));
 }