예제 #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);
        }
예제 #2
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);
        }