Esempio n. 1
0
        public static string GetPhoneNumber(RestCommand command, int phoneID)
        {
            PhoneNumber phoneNumber = PhoneNumbers.GetPhoneNumber(command.LoginUser, phoneID);

            if (phoneNumber.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(phoneNumber.GetXml("PhoneNumber", true));
        }
    private void LoadPhone(int phoneID)
    {
        PhoneNumber phoneNumber = (PhoneNumber)PhoneNumbers.GetPhoneNumber(UserSession.LoginUser, phoneID);

        if (phoneNumber != null)
        {
            edtPhoneNumber.Text    = phoneNumber.Number;
            edtExtension.Text      = phoneNumber.Extension;
            cmbTypes.SelectedValue = phoneNumber.PhoneTypeID.ToString();
        }
    }
        public static string UpdatePhoneNumber(RestCommand command, int phoneID)
        {
            PhoneNumber item = PhoneNumbers.GetPhoneNumber(command.LoginUser, phoneID);

            if (!DataUtils.IsReferenceValid(command.LoginUser, item.RefType, item.RefID))
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            item.ReadFromXml(command.Data, false);
            item.Collection.Save();
            return("");
        }
        public static string RemovePhoneNumber(RestCommand command, ReferenceType refType, int refID, int phoneID)
        {
            PhoneNumber item = PhoneNumbers.GetPhoneNumber(command.LoginUser, phoneID);

            if (item.RefType != refType && item.RefID != refID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            if (!DataUtils.IsReferenceValid(command.LoginUser, refType, refID))
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            item.Delete();
            item.Collection.Save();
            return("");
        }