Exemplo n.º 1
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //Validation of parameters and user have been successful. We may now proceed to read from the database
            var adoCopyright = new Copyright_ADO();

            //First we must check if the group exists already (we can't have duplicates)
            if (adoCopyright.Exists(Ado, DTO.CprCode))
            {
                //This copyright exists already, we can't proceed
                Log.Instance.Debug("Copyright exists already - create request refused");
                Response.error = Label.Get("error.duplicate");
                return(false);
            }

            //Create the copyright - and retrieve the newly created Id
            int newId = adoCopyright.Create(Ado, DTO, SamAccountName);

            if (newId == 0)
            {
                Log.Instance.Debug("Can't create copyright");
                Response.error = Label.Get("error.create");
                return(false);
            }
            Response.data = JSONRPC.success;
            return(true);
        }
Exemplo n.º 2
0
        internal Copyright_DTO_Create ReadFromValue(string CprValue)
        {
            ADO Ado = new ADO("defaultConnection");

            try
            {
                Copyright_DTO_Create dto = new Copyright_DTO_Create();

                Copyright_ADO      cAdo    = new Copyright_ADO();
                Copyright_DTO_Read readDTO = new Copyright_DTO_Read();
                readDTO.CprValue = CprValue;
                var retval = cAdo.Read(Ado, readDTO);
                if (retval.hasData)
                {
                    dto.CprCode  = retval.data[0].CprCode;
                    dto.CprValue = CprValue;
                    dto.CprUrl   = retval.data[0].CprUrl;
                }

                return(dto);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Ado.Dispose();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Copyright_ADO adoCopyright = new Copyright_ADO();

            //First we must check if the amended Copyright code exists already (we can't have duplicates)
            if (!DTO.CprCodeNew.Equals(DTO.CprCodeOld))
            {
                if (adoCopyright.Exists(Ado, DTO.CprCodeNew))
                {
                    //The proposed new copyright code exists already, we can't proceed
                    Log.Instance.Debug("Copyright code exists already - create request refused");
                    Response.error = Label.Get("error.duplicate");
                    return(false);
                }
            }

            //Update and retrieve the number of updated rows
            int nUpdated = adoCopyright.Update(Ado, DTO, SamAccountName);

            if (nUpdated == 0)
            {
                Log.Instance.Debug("Can't update Copyright");
                Response.error = Label.Get("error.update");
                return(true);
            }

            Response.data = JSONRPC.success;
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //Validation of parameters and user have been successful. We may now proceed to read from the database
            var adoCopyright = new Copyright_ADO();

            //Copyrights are returned as an ADO result
            ADO_readerOutput result = adoCopyright.Read(Ado, DTO);

            if (!result.hasData)
            {
                return(false);
            }

            Response.data = result.data;

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Copyright_ADO adoCopyright = new Copyright_ADO();

            if (adoCopyright.IsInUse(Ado, DTO.CprCode))
            {
                Log.Instance.Debug("Delete request for Copyright Code: " + DTO.CprCode + " refused because it is in use by at least one related entity");
                Response.error = Label.Get("error.delete");
                return(false);
            }

            //attempting to delete. The number of entities deleted are passed to the entitiesDeleted variable (this is 1 for a successful delete)
            int nDeleted = adoCopyright.Delete(Ado, DTO, SamAccountName);

            if (nDeleted == 0)
            {
                Log.Instance.Debug("No record found for delete request");
                Response.error = Label.Get("error.delete");
                return(false);
            }

            Response.data = JSONRPC.success;
            return(true);
        }