示例#1
0
        public ApiResponse Update(int id, Alcada alcada)
        {
            ApiResponse resp = new ApiResponse();

            if (alcada == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Conteudo vazio");
                return(resp);
            }

            if (string.IsNullOrEmpty(alcada.s_descricao) == true)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Descricao nao informada");
                return(resp);
            }

            DAOBase <Alcada> daoA = new DAOBase <Alcada>();
            Alcada           a    = daoA.GetById(id);

            if (a == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Alcada: " + alcada + " informada inexistente");
                return(resp);
            }

            // atriuicao dos valores
            a.s_descricao = alcada.s_descricao;

            try
            {
                daoA.Update(a);

                resp.Success = true;
                resp.data    = a;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
示例#2
0
        public ApiResponse Delete(int id)
        {
            ApiResponse resp = new ApiResponse();

            if (id <= 0)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Alcada nao informada");
                return(resp);
            }

            DAOBase <Alcada> daoAlacada = new DAOBase <Alcada>();
            Alcada           a          = daoAlacada.GetById(id);

            if (a == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Alcada: " + id + " informada inexistente");
                return(resp);
            }

            try
            {
                daoAlacada.Delete(a);
                resp.Success = true;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
示例#3
0
        public ApiResponse Create(Alcada alcada)
        {
            ApiResponse resp = new ApiResponse();

            if (alcada == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Conteudo vazio");
                return(resp);
            }

            if (string.IsNullOrEmpty(alcada.s_descricao) == true)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Descricao nao informada");
                return(resp);
            }

            try
            {
                DAOBase <Alcada> daoA = new DAOBase <Alcada>();
                daoA.Insert(alcada);

                resp.Success = true;
                resp.data    = alcada;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }