Beispiel #1
0
        /// <summary>
        /// Update client with new list
        /// </summary>
        /// <param name="id_client">ID user master</param>
        /// <param name="id_lista">ID new list</param>
        /// <param name="id_pauta">ID guide (for traceability)</param>
        /// <returns></returns>
        public ActionResponse UpdateClientListAction(decimal id_client, decimal id_lista, decimal id_pauta)
        {
            ActionResponse output = new ActionResponse();

            try
            {
                // Verify if user exists
                ClienteData clientData = new ClienteData();
                Cliente     oClient    = clientData.GetUserById(id_client);
                if (oClient.id_cliente == null)
                {
                    return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "No existe el usuario en el sistema", null));
                }

                ListData listData = new ListData();

                // If everything is ok, try to close it
                int res = listData.UpdateClientList(id_client, id_lista, id_pauta);
                if (res <= 0)
                {
                    return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, "No se pudo actualizar el estado del usuario/lista", null));
                }

                CloseCustodyResponse response = new CloseCustodyResponse();
                response.updated = DateTime.Now;
                return(functions.Response((int)CodeStatusEnum.OK, "OK", response));
            }
            catch (Exception e)
            {
                logger.Fatal(e.Message);
                return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, e.Message, null));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Will close Custody object
        /// </summary>
        /// <param name="idCustody">ID Custody</param>
        /// <returns></returns>
        public ActionResponse CloseCustodyByIdAction(int idCustody)
        {
            ActionResponse output = new ActionResponse();

            try
            {
                CustodyData custodyData = new CustodyData();

                // Check if custody exists or not
                Custody oCustody = custodyData.GetCustodyById(idCustody);
                if (oCustody == null)
                {
                    return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "No existe ninguna custodia asociada al identificador", null));
                }

                // If custody exists, verify if custody is valid or not
                ActionResponse isCustodyValid = IsCustodyValid(oCustody);
                if (isCustodyValid.code != (int)CodeStatusEnum.OK)
                {
                    return(functions.Response(isCustodyValid.code, isCustodyValid.message, null));
                }

                // If everything is ok, try to close it
                int res = custodyData.CloseCustody(idCustody);
                if (res <= 0)
                {
                    return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, "No se pudo actualizar el estado de la custodia", null));
                }

                CloseCustodyResponse response = new CloseCustodyResponse();
                response.updated = DateTime.Now;
                return(functions.Response((int)CodeStatusEnum.OK, "OK", response));
            }
            catch (Exception e)
            {
                logger.Fatal(e.Message);
                return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, e.Message, null));
            }
        }